{"record":{"id":"4a872ac1c1aa854d","repo":"cross-rs/cross","slug":"workspace-root-can-t-end-in","errorCode":null,"errorMessage":"workspace_root can't end in `..`","messagePattern":"workspace_root can't end in `\\.\\.`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/docker/custom.rs","lineNumber":233,"sourceCode":"        match self {\n            Dockerfile::File { runs_with, .. } => runs_with,\n            Dockerfile::Custom { runs_with, .. } => runs_with,\n        }\n    }\n}\n\nfn docker_package_name(metadata: &CargoMetadata) -> String {\n    // a valid image name consists of the following:\n    // - lowercase ASCII letters\n    // - digits\n    // - a period\n    // - 1-2 underscores\n    // - 1 or more hyphens (dashes)\n    docker_tag_name(\n        &metadata\n            .workspace_root\n            .file_name()\n            .expect(\"workspace_root can't end in `..`\")\n            .to_string_lossy(),\n    )\n}\n\nfn docker_tag_name(file_name: &str) -> String {\n    // a valid image name consists of the following:\n    // - lowercase ASCII letters\n    // - digits\n    // - a period\n    // - 1-2 underscores\n    // - 1 or more hyphens (dashes)\n    let mut result = String::new();\n    let mut consecutive_underscores = 0;\n    for c in file_name.chars() {\n        match c {\n            'a'..='z' | '0'..='9' | '.' | '-' => {\n                consecutive_underscores = 0;\n                result.push(c);","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/custom.rs#L215-L251","documentation":"`docker_package_name` (src/docker/custom.rs:233) derives the default Docker image name from `metadata.workspace_root.file_name()`. `Path::file_name()` returns None when the path ends in `..`, a root, or is empty, so the code calls `expect(\"workspace_root can't end in `..`\")` to fail fast with an explanatory message instead of silently producing a bad image name.","triggerScenarios":"Calling cargo metadata / cross with a workspace_root PathBuf whose final component is `..` (e.g. `--manifest-path` or cwd resolving to `foo/..`), or an empty/root path from a corrupted metadata result.","commonSituations":"Running cross from or pointing at a path like `/path/to/project/..` (via shell `cd ..` composed paths, symlinks resolved oddly, or CARGO_MANIFEST_DIR set to a `..`-terminated path); building Docker images for the project then fails.","solutions":["Run cross from inside the project directory or pass a canonicalized manifest path (`realpath Cargo.toml`)","Ensure workspace_root resolves to a real directory name, not a `..` component","If invoking programmatically, canonicalize the path with `std::fs::canonicalize` before passing it"],"exampleFix":"// before\ncross build --target x86_64-unknown-linux-musl  # run from /repo/sub/..\n// after\ncd /repo && cross build --target x86_64-unknown-linux-musl","handlingStrategy":"validation","validationCode":"let root = std::fs::canonicalize(&workspace_root)?;\nassert!(root.file_name().is_some(), \"workspace_root must end in a real directory name, not `..`\");","typeGuard":"fn has_file_name(p: &std::path::Path) -> bool { p.file_name().is_some() }","tryCatchPattern":null,"preventionTips":["Always run cross from inside the project directory","Canonicalize paths (realpath) before passing --manifest-path or setting CARGO_MANIFEST_DIR","Avoid composing workspace paths with trailing `..` in scripts/CI"],"tags":["docker","path","workspace-root"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}