1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 09:49:36 +01:00

libstore: Call canonPath for constructing LocalFSStoreConfig::rootDir

This mirrors what OptionalPathSetting does. Otherwise we run into
an assertion failure for relative paths specified as the authority + path:

nix build nixpkgs#hello --store "local://a/b"
nix: ../posix-source-accessor.cc:13: nix::PosixSourceAccessor::PosixSourceAccessor(std::filesystem::__cxx11::path&&): Assertion `root.empty() || root.is_absolute()' failed.

This is now diagnosed properly:

error: not an absolute path: 'a/b'

Just as you'd specify the root via a query parameter:

nix build nixpkgs#hello --store "local?root=a/b"
This commit is contained in:
Sergei Zimmerman 2025-09-28 17:42:19 +03:00
parent 7817239644
commit 3a64d3c0da
No known key found for this signature in database

View file

@ -24,7 +24,7 @@ LocalFSStoreConfig::LocalFSStoreConfig(PathView rootDir, const Params & params)
// FIXME don't duplicate description once we don't have root setting // FIXME don't duplicate description once we don't have root setting
, rootDir{ , rootDir{
this, this,
!rootDir.empty() && params.count("root") == 0 ? (std::optional<Path>{rootDir}) : std::nullopt, !rootDir.empty() && params.count("root") == 0 ? (std::optional{canonPath(rootDir)}) : std::nullopt,
"root", "root",
"Directory prefixed to all other paths."} "Directory prefixed to all other paths."}
{ {