cross-rs/cross · error
unable to find provided nix-store directory
Error message
unable to find provided nix-store directory {store:?} What it means
In the Nix cross-compilation path, `assemble` accepts a user-supplied nix-store directory. If one was explicitly provided (via config/flag) but does not exist on disk, it fails rather than silently falling back to the default store path.
Solutions
- Verify the configured nix-store path exists: `ls /nix/store` or the custom path; fix typos.
- Remove the custom nix-store override so the default `/nix/store` is used when it exists.
- Ensure you're running inside the Nix environment (nix-shell/nix develop) where the store is mounted.
Example fix
// before
let opts = Options { nix_store: Some("/nx/store".into()), .. } // typo
// after
let opts = Options { nix_store: Some("/nix/store".into()), .. } Defensive patterns
Strategy: validation
Validate before calling
if let Some(store) = &opts.nix_store {
if !store.exists() {
return Err(format!("nix-store path {} does not exist", store.display()));
}
} Type guard
fn valid_nix_store(p: &std::path::Path) -> bool { p.is_dir() } Prevention
- Only set a custom nix-store path after verifying it exists on the build machine.
- Prefer running inside nix-shell/nix develop so the default /nix/store is present.
- Canonicalize the configured path in config-loading code to catch typos early.
When it happens
Trigger: Calling `assemble` with `nix_store = Some(path)` where `path.exists()` is false — e.g. a custom store path pointing to a non-existent or typo'd directory.
Common situations: Nix store mounted at a non-default location that was moved/deleted, running outside the Nix environment where the configured store path doesn't exist, typos in config, or chroot/container contexts lacking the mount.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- failed to serialize CrossToml as object
- unix paths cannot handle windows prefix
- unsupported rust target for file
- invalid linux version, got
- workspace_root can't end in `..`
AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13).
Data as JSON: /api/errors/16152f09e1cd2b12.
Report an issue: GitHub.
Appendix: source
Thrown at src/docker/shared.rs:293
if let Some(ref nix_store) = nix_store {
file::create_dir_all(nix_store)?;
}
// get our mount paths prior to canonicalizing them
let cargo_mount_path = cargo.as_posix_absolute()?;
// now that we know the paths exist, canonicalize them. this avoids creating
// directories after failed canonicalization into a shared directory.
let cargo = file::canonicalize(&cargo)?;
let default_nix_store = PathBuf::from("/nix/store");
let nix_store = match nix_store {
Some(store) if store.exists() => {
let path = file::canonicalize(store)?;
Some(path)
}
Some(store) => {
eyre::bail!("unable to find provided nix-store directory {store:?}");
}
None if cfg!(target_os = "linux") && default_nix_store.exists() => {
Some(default_nix_store)
}
None => None,
};
let cargo = mount_finder.find_mount_path(cargo);
// canonicalize these once to avoid syscalls
let sysroot_mount_path = toolchain.get_sysroot().as_posix_absolute()?;
Ok(ToolchainDirectories {
cargo,
nix_store,
toolchain,
cargo_mount_path,
sysroot_mount_path,View on GitHub (pinned to 8c1a8aa4b6)