Merge pull request #6739 from edolstra/ignore-chroot-error

Don't fail if we can't create ~/.local/share/nix/root
This commit is contained in:
Eelco Dolstra 2022-06-29 13:06:35 +02:00 committed by GitHub
commit 7633764342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1326,9 +1326,14 @@ std::shared_ptr<Store> openFromNonUri(const std::string & uri, const Store::Para
we're not root, then automatically set up a chroot
store in ~/.local/share/nix/root. */
auto chrootStore = getDataDir() + "/nix/root";
if (!pathExists(chrootStore))
if (!pathExists(chrootStore)) {
try {
createDirs(chrootStore);
} catch (Error & e) {
return std::make_shared<LocalStore>(params);
}
warn("'/nix' does not exist, so Nix will use '%s' as a chroot store", chrootStore);
else
} else
debug("'/nix' does not exist, so Nix will use '%s' as a chroot store", chrootStore);
Store::Params params2;
params2["root"] = chrootStore;