ensure_datadir/2 fails for non-local installation of Ciao
ony opened this issue · 2 comments
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
Related code seems to be:
ciao/core/library/persdb/datadir.pl
Lines 64 to 67 in f6d7b15
ciao/builder/src/config_common.pl
Lines 82 to 92 in f6d7b15
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.
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.