jdx/mise · error

copy_link cannot be nested below a symbolic link

Error message

copy_link cannot be nested below a symbolic link: {}

What it means

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.

Solutions

  1. Configure the copy_link to point at a symlink whose parent directories are real directories
  2. Replace the symlinked intermediate directory with a real directory (or a bind mount)
  3. Reference the symlink directly at the top level of the source instead of beneath another symlink
  4. Set copy_links=true to copy all symlinks as links without per-link parent validation

Example fix

// before: 'current/tools/link' where 'current' is a symlink
copy_link = "current/tools/link"
// after: point at a top-level real path
copy_link = "tools/link"
Defensive patterns

Strategy: validation

Validate before calling

# ensure no ancestor of the link is a symlink
p="$(dirname "$LINK_REL")"
while [ "$p" != "." ]; do
  [ -L "$SOURCE_DIR/$p" ] && { echo "$p is a symlink"; exit 1; }
  p="$(dirname "$p")"
done

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/c44fd92b0f210158. Report an issue: GitHub.

Appendix: source

Thrown at src/system/remote.rs:856

                component,
                Component::ParentDir | Component::RootDir | Component::Prefix(_)
            )
        })
    {
        bail!(
            "copy_link must be a relative path within the source: {}",
            link.display()
        );
    }
    let mut parent = source.to_path_buf();
    for component in link.parent().unwrap_or_else(|| Path::new("")).components() {
        if let Component::Normal(component) = component {
            parent.push(component);
            let metadata = fs::symlink_metadata(&parent).wrap_err_with(|| {
                format!("copy_link parent does not exist: {}", parent.display())
            })?;
            if metadata.file_type().is_symlink() {
                bail!(
                    "copy_link cannot be nested below a symbolic link: {}",
                    link.display()
                );
            }
        }
    }
    let path = source.join(link);
    let metadata = fs::symlink_metadata(&path)
        .wrap_err_with(|| format!("copy_link does not exist: {}", link.display()))?;
    if !metadata.file_type().is_symlink() {
        bail!("copy_link is not a symbolic link: {}", link.display());
    }
    Ok(())
}

fn materialize_link(source: &Path, staged_source: &Path, link: &Path) -> Result<()> {
    validate_copy_link_path(staged_source, link)
        .wrap_err_with(|| format!("staged copy_link is unsafe: {}", link.display()))?;

View on GitHub (pinned to 533346cc37)