{"record":{"id":"29ecdc84a3835ee5","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-canonicalize-manifest-dir-path-err","errorCode":null,"errorMessage":"Failed to canonicalize manifest_dir path {}: {err:#?}","messagePattern":"Failed to canonicalize manifest_dir path (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/build.rs","lineNumber":322,"sourceCode":"    code.push_str(&format!(\"        templates.insert(\\\"{}\\\", files);\\n\", source));\n    code.push_str(\"    }\\n\\n\");\n}\n\n/// Get a list of files tracked by git from a given directory\nfn get_git_tracked_files(path: &Path, manifest_dir: &Path) -> (Vec<PathBuf>, PathBuf) {\n    if is_nix_build() {\n        // When building in Nix, we already know that there are no untracked files in our source tree,\n        // so we just list all of the files.\n        list_all_files(path, manifest_dir)\n    } else {\n        // When building outside of Nix, we invoke `git` to list all the tracked files.\n        get_git_tracked_files_via_cli(path, manifest_dir)\n    }\n}\n\nfn list_all_files(path: &Path, manifest_dir: &Path) -> (Vec<PathBuf>, PathBuf) {\n    let manifest_dir = manifest_dir.canonicalize().unwrap_or_else(|err| {\n        panic!(\n            \"Failed to canonicalize manifest_dir path {}: {err:#?}\",\n            manifest_dir.display()\n        )\n    });\n\n    let template_root_absolute = get_full_path_within_manifest_dir(path, &manifest_dir);\n\n    let repo_root = get_repo_root();\n\n    let mut files = Vec::new();\n    ls_recursively(&template_root_absolute, &repo_root, &mut files);\n\n    (files, make_repo_root_relative(&template_root_absolute, &repo_root))\n}\n\n/// Get all the paths of files within `root_dir`,\n/// transform them into paths relative to `repo_root`,\n/// and insert them into `out`.","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/build.rs#L304-L340","documentation":"Build-time panic in crates/cli/build.rs during the Nix-build path (`list_all_files`): `manifest_dir.canonicalize()` failed, i.e. the crates/cli directory recorded in CARGO_MANIFEST_DIR could not be resolved to a real absolute path. Canonicalization fails when the path does not exist, a path component is a dangling symlink, or permissions forbid traversal — an abnormal state for the crate cargo is currently building.","triggerScenarios":"Running a Nix build where the source was garbage-collected or moved mid-build; a sandboxed builder that replaces directories with symlinks pointing outside the sandbox; stale CARGO_MANIFEST_DIR inherited from a previous build in a deleted target dir.","commonSituations":"Incremental builds after the checkout was relocated; Nix sandboxing oddities with bind-mounted paths; concurrently running two cargo invocations where one cleans the tree.","solutions":["Verify the path exists from the failing environment: `ls \"$CARGO_MANIFEST_DIR\"` and `readlink -f` each component to find the dangling symlink.","Do a clean build (`cargo clean` or a fresh Nix store source) to eliminate a half-deleted target/checkout.","If a wrapper sets CARGO_MANIFEST_DIR manually, remove that override and let cargo provide it.","Check permissions on every path component (execute bit) for the build user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Before building: every component of the manifest dir must resolve.\npath=\"$CARGO_MANIFEST_DIR\"\nwhile [ \"$path\" != \"/\" ]; do\n  [ -e \"$path\" ] || { echo \"missing component: $path\"; exit 1; }\n  path=$(dirname \"$path\")\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build from a stable checkout; don't move or delete the tree while cargo runs.","Avoid dangling symlinks anywhere in the manifest path.","Don't override CARGO_MANIFEST_DIR manually in wrappers."],"tags":["spacetimedb","build-script","path-canonicalization","nix"],"backgroundTag":"path-canonicalization-failed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}