Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure_datadir/2 fails for non-local installation of Ciao #50

Open
ony opened this issue Apr 30, 2022 · 2 comments
Open

ensure_datadir/2 fails for non-local installation of Ciao #50

ony opened this issue Apr 30, 2022 · 2 comments

Comments

@ony
Copy link

ony commented Apr 30, 2022

Looks like persdb/datadir tries to use system path for data dir (probably relative to core/builder bundles or CIAOROOT folders).

Can be reproduced with Nix packaged version (example for Flakes flavor):

nix run nixpkgs\#ciao
use_module(library(persdb/datadir)). ensure_datadir('learn-ciao', Dir).
zsh%  nix run nixpkgs\#ciao
Ciao 1.20.0 [LINUXx86_64]
?- use_module(library(persdb/datadir)). ensure_datadir('learn-ciao', Dir).

yes
?- {ERROR: system:make_directory/2, arg 1 - system error: Read-only file system}

In NixOS packages installed at location that is perceived as read-only for normal users.

P.S. This at least affects ciaopp. See ciao-lang/ciaopp#2

@ony
Copy link
Author

ony commented Apr 30, 2022

Related code seems to be:

get_datadir(RelPath, D) :-
% Otherwise, use a local data path
data_root_dir(Dir0),
D = ~path_concat(Dir0, RelPath).

:- export(site_root_dir/1).
% Files for HTTP serving
site_root_dir := Path :-
Bundle = core, % TODO: allow any bundle
Path = ~bundle_path(Bundle, builddir, 'site').
:- export(data_root_dir/1).
% Files for per-bundle persistence
data_root_dir := Path :-
Bundle = core, % TODO: allow any bundle
Path = ~bundle_path(Bundle, builddir, 'data').

With core bundle being installed into system location and not allowed for write - these setup is not going to fully work.

Shouldn't persistence always fallback to something like $XDG_STATE_HOME/~/.local/state (maybe with some versioning) on Unix. If persdb indeed allows multi-user access with updates, then it probably should use /var/db with appropriate permissions install.

@jfmc
Copy link
Member

jfmc commented Apr 30, 2022

Thank you @ony for the fantastic analysis of the problem and your proposed solution. Indeed Ciao needs a few user-writable directories for caching compilation and analysis data. Also commands like ciao get ... requires a user-writable directory to download and compile sources. This is well tested for local installations but not for system-wide configurations.

It will be awesome to finally fix those issues. I've seen that other systems (like npm already have or had) issues with globally installing packages since nix store is immutable. Most of the solutions I've seen are a mix of global immutable installation + local home subdirectory for packages. We'd really appreciate if you can point us to any good accepted solution for those problems, specially if it works both in different Linux distributions and macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants