{"record":{"id":"90b0aac38de026d4","repo":"cross-rs/cross","slug":"copied-directory-contained-symlinks-if-the-volume-the-link","errorCode":null,"errorMessage":"copied directory contained symlinks. if the volume the link points to was not mounted, the remote build may fail","messagePattern":"copied directory contained symlinks\\. if the volume the link points to was not mounted, the remote build may fail","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/docker/remote.rs","lineNumber":515,"sourceCode":"                };\n                if link_dst_absolute.is_dir() {\n                    std::os::windows::fs::symlink_dir(link_dst, dst_path)?;\n                } else {\n                    // symlink_file handles everything that isn't a directory\n                    std::os::windows::fs::symlink_file(link_dst, dst_path)?;\n                }\n            }\n        } else {\n            had_symlinks = true;\n        }\n    }\n\n    Ok(had_symlinks)\n}\n\nfn warn_symlinks(had_symlinks: bool, msg_info: &mut MessageInfo) -> Result<()> {\n    if had_symlinks {\n        msg_info.warn(\"copied directory contained symlinks. if the volume the link points to was not mounted, the remote build may fail\")\n    } else {\n        Ok(())\n    }\n}\n\n#[derive(Debug, Deserialize)]\nstruct CargoCompilerArtifact {\n    reason: String,\n    package_id: String,\n    filenames: Vec<String>,\n    executable: Option<String>,\n}\n\n/// Artifacts of workspace members have `path+file://` package ids,\n/// while registry and git dependencies have `registry+`/`git+` ids.\n/// Only the former should be copied back to the host.\nfn is_workspace_artifact(artifact: &CargoCompilerArtifact) -> bool {\n    artifact.package_id.starts_with(\"path+file://\")","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/remote.rs#L497-L533","documentation":"Before copying directories into a remote build volume, cross scans for symbolic links (warn_symlinks after the scan reports had_symlinks). If any symlinks were found, it warns that unless the symlink target's volume is also mounted, the remote docker build may fail because the link will dangle inside the build context.","triggerScenarios":"Calling copy_files_nocache, copy_rust_base, or copy_rust_manifest on a directory that contains symlinked files/dirs during a remote (cluster) build.","commonSituations":"Cargo home directories containing symlinked toolchains (rustup uses symlinks heavily); project dirs with symlinks into node_modules or vendored dependencies; shared caches linked from elsewhere on disk.","solutions":["Replace symlinks in the copied directory with real files/directories (e.g. `rsync -L` or `cp -rL`) before the remote build.","Configure cross to mount the volume the symlinks point to so the links resolve in the container.","For rustup-managed toolchains, use cross's own toolchain volume management (`cross-util volumes create`) rather than copying a host rustup dir."],"exampleFix":"# before: directory contains symlinks\ncross build --target aarch64-unknown-linux-gnu\n\n# after: dereference symlinks into a clean copy\nrsync -rL ~/.cargo /tmp/cargo-copy\ncross build --target aarch64-unknown-linux-gnu","handlingStrategy":"validation","validationCode":"// Scan the directory for symlinks before a remote build\nuse std::fs;\nfn contains_symlinks(dir: &std::path::Path) -> std::io::Result<bool> {\n    for e in fs::read_dir(dir)? {\n        let p = e?.path();\n        if fs::symlink_metadata(&p)?.file_type().is_symlink() { return Ok(true); }\n        if p.is_dir() { return contains_symlinks(&p); }\n    }\n    Ok(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Dereference symlinks (rsync -rL / cp -rL) before remote builds","Avoid copying rustup-managed toolchain dirs; let cross manage its volumes","Mount any volume a symlink points to when nesting is required"],"tags":["docker","remote","symlink","volume"],"backgroundTag":"unsupported-operation","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"}