{"record":{"id":"c44fd92b0f210158","repo":"jdx/mise","slug":"copy-link-cannot-be-nested-below-a-symbolic-link","errorCode":null,"errorMessage":"copy_link cannot be nested below a symbolic link: {}","messagePattern":"copy_link cannot be nested below a symbolic link: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":856,"sourceCode":"                component,\n                Component::ParentDir | Component::RootDir | Component::Prefix(_)\n            )\n        })\n    {\n        bail!(\n            \"copy_link must be a relative path within the source: {}\",\n            link.display()\n        );\n    }\n    let mut parent = source.to_path_buf();\n    for component in link.parent().unwrap_or_else(|| Path::new(\"\")).components() {\n        if let Component::Normal(component) = component {\n            parent.push(component);\n            let metadata = fs::symlink_metadata(&parent).wrap_err_with(|| {\n                format!(\"copy_link parent does not exist: {}\", parent.display())\n            })?;\n            if metadata.file_type().is_symlink() {\n                bail!(\n                    \"copy_link cannot be nested below a symbolic link: {}\",\n                    link.display()\n                );\n            }\n        }\n    }\n    let path = source.join(link);\n    let metadata = fs::symlink_metadata(&path)\n        .wrap_err_with(|| format!(\"copy_link does not exist: {}\", link.display()))?;\n    if !metadata.file_type().is_symlink() {\n        bail!(\"copy_link is not a symbolic link: {}\", link.display());\n    }\n    Ok(())\n}\n\nfn materialize_link(source: &Path, staged_source: &Path, link: &Path) -> Result<()> {\n    validate_copy_link_path(staged_source, link)\n        .wrap_err_with(|| format!(\"staged copy_link is unsafe: {}\", link.display()))?;","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L838-L874","documentation":"mise resolves each parent directory of a copy_link in the staged copy and refuses to continue through a symbolic link, because the link's real location is unknown for staging. This error means an ancestor directory of the configured link is itself a symlink, so the copy_link could silently point outside the staged tree.","triggerScenarios":"validate_copy_link_path walks link.parent() components with symlink_metadata; any intermediate directory (e.g. `vendor` in `vendor/tools/link`) is a symlink on disk.","commonSituations":"Project uses symlinked directories like `node_modules` -> shared cache, `current` -> release dir, or symlinked vendor folders, and a nested symlink is configured as copy_link.","solutions":["Configure the copy_link to point at a symlink whose parent directories are real directories","Replace the symlinked intermediate directory with a real directory (or a bind mount)","Reference the symlink directly at the top level of the source instead of beneath another symlink","Set copy_links=true to copy all symlinks as links without per-link parent validation"],"exampleFix":"// before: 'current/tools/link' where 'current' is a symlink\ncopy_link = \"current/tools/link\"\n// after: point at a top-level real path\ncopy_link = \"tools/link\"","handlingStrategy":"validation","validationCode":"# ensure no ancestor of the link is a symlink\np=\"$(dirname \"$LINK_REL\")\"\nwhile [ \"$p\" != \".\" ]; do\n  [ -L \"$SOURCE_DIR/$p\" ] && { echo \"$p is a symlink\"; exit 1; }\n  p=\"$(dirname \"$p\")\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep copy_link parent directories as real directories","Avoid referencing symlinks nested inside symlinked dirs (current/, node_modules/)","Prefer top-level copy_link entries inside the project"],"tags":["symlink","path-validation","config"],"backgroundTag":"path-traversal-blocked","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}