{"record":{"id":"524e2a5cfffe23f0","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-canonicalize-repo-root-path-err","errorCode":null,"errorMessage":"Failed to canonicalize repo_root path {}: {err:#?}","messagePattern":"Failed to canonicalize repo_root path (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/build.rs","lineNumber":399,"sourceCode":"///\n/// `full_path` and `repo_root` should both be canonical paths, as by [`Path::canonicalize`].\nfn make_repo_root_relative(full_path: &Path, repo_root: &Path) -> PathBuf {\n    full_path\n        .strip_prefix(repo_root)\n        .map(|p| p.to_path_buf())\n        .unwrap_or_else(|_| {\n            panic!(\n                \"Path {} is outside repo root {}\",\n                full_path.display(),\n                repo_root.display()\n            )\n        })\n}\n\nfn get_git_tracked_files_via_cli(path: &Path, manifest_dir: &Path) -> (Vec<PathBuf>, PathBuf) {\n    let repo_root = get_repo_root();\n    let repo_root = repo_root.canonicalize().unwrap_or_else(|err| {\n        panic!(\n            \"Failed to canonicalize repo_root path {}: {err:#?}\",\n            repo_root.display(),\n        )\n    });\n\n    let resolved_path = make_repo_root_relative(&get_full_path_within_manifest_dir(path, manifest_dir), &repo_root);\n\n    let output = Command::new(\"git\")\n        .args([\"ls-files\", resolved_path.to_str().unwrap()])\n        .current_dir(repo_root)\n        .output()\n        .expect(\"Failed to execute git ls-files\");\n\n    if !output.status.success() {\n        return (Vec::new(), resolved_path);\n    }\n\n    let stdout = String::from_utf8(output.stdout).unwrap();","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/build.rs#L381-L417","documentation":"Build-time panic in crates/cli/build.rs: canonicalizing the repository root failed inside `get_git_tracked_files_via_cli`, the non-Nix path that shells out to `git ls-files`. The root is derived from CARGO_MANIFEST_DIR (`crates/cli/../..`); canonicalize fails when that computed path cannot be resolved — the checkout was moved/deleted mid-build, a parent directory is a dangling symlink, or the crate is built outside the expected two-level directory layout.","triggerScenarios":"Building the CLI crate after the repo directory was renamed or removed while cargo still held the old CARGO_MANIFEST_DIR; vendoring crates/cli into another project at a different depth so `../..` no longer lands on the repo root; dangling symlinks in parent directories.","commonSituations":"Relocating/cleaning the workspace during an incremental build; extracting the crate alone from a source archive; unusual filesystem mounts under Nix/FUSE.","solutions":["Confirm the layout: the crate must live at `<repo_root>/crates/cli`; build from a full SpacetimeDB checkout.","Re-run from a fresh, stable checkout (`git clone` again) to eliminate moved/deleted-directory races.","Check every component of the printed path with `readlink -f` for dangling symlinks.","If you must build outside the repo, use the Nix path by setting SPACETIMEDB_NIX_BUILD_GIT_COMMIT so git metadata is not consulted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Ensure the crate sits at <root>/crates/cli and the root resolves:\ncase \"$CARGO_MANIFEST_DIR\" in\n  */crates/cli) [ -d \"$CARGO_MANIFEST_DIR/../..\" ] || echo \"repo root missing\";;\n  *) echo \"unexpected layout: $CARGO_MANIFEST_DIR\";;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the CLI only from a full SpacetimeDB checkout with the standard directory layout.","Don't relocate or delete the checkout while builds run.","Use the Nix build path for out-of-tree builds where git isn't available."],"tags":["spacetimedb","build-script","path-canonicalization","git","repo-root"],"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-14T00:17:10.932Z"}