aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-06-29 13:06:35 +0200
committerGitHub <noreply@github.com>2022-06-29 13:06:35 +0200
commit7633764342ce9ddadbf209c17faf10004b3372b6 (patch)
treeb30c657436d0f613a88c079dddd882a559f9691b
parent865af66112b22ff8317f287afa42d2ffe407e3bc (diff)
parent6cab5284614991ea3622492eacdceb3caf52ccff (diff)
Merge pull request #6739 from edolstra/ignore-chroot-error
Don't fail if we can't create ~/.local/share/nix/root
-rw-r--r--src/libstore/store-api.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 53b1a8777..05353bce2 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -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;