jdx/mise · error

copy_link must be a relative path within the source

Error message

copy_link must be a relative path within the source: {}

What it means

When `copy_link` entries are configured for a remote source, each must be a relative path that stays inside the source directory and names a symbolic link. This error fires when the given link path is empty, absolute, or contains `..`, root, or prefix components, which would make the copy escape the source. mise rejects it before touching any files.

Solutions

  1. Rewrite the copy_link value as a path relative to the source directory (e.g. `.claude` instead of `/home/me/project/.claude`)
  2. Remove any `..` segments by restructuring the link inside the project
  3. If the symlink lives outside the source, create an in-project symlink to it and reference that instead
  4. Use copy_links=true to copy all links if per-link selection is not needed

Example fix

// before
copy_link = "/home/me/project/.claude"
// after
copy_link = ".claude"
Defensive patterns

Strategy: validation

Validate before calling

// Rust-side preflight mirroring mise's rule
fn is_valid_copy_link(link: &Path) -> bool {
    !link.as_os_str().is_empty()
        && !link.is_absolute()
        && !link.components().any(|c| matches!(c,
            std::path::Component::ParentDir
            | std::path::Component::RootDir
            | std::path::Component::Prefix(_)))
}

Prevention

When it happens

Trigger: Configuring a RemoteHost with copy_link containing e.g. "/abs/link", "../link", "", or a path with ParentDir/RootDir/Prefix components; validation runs in validate_copy_link_path during upload_source.

Common situations: User pastes an absolute path of the symlink instead of one relative to the source directory; a config with `../shared/link` intended to point outside the project; an empty copy_link setting combined with copy_links=false.

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/7b44af5429c11e96. Report an issue: GitHub.

Appendix: source

Thrown at src/system/remote.rs:843

fn validate_copy_link(source: &Path, link: &Path) -> Result<()> {
    validate_copy_link_path(source, link)?;
    let path = source.join(link);
    fs::metadata(&path)
        .wrap_err_with(|| format!("copy_link target does not exist: {}", link.display()))?;
    Ok(())
}

fn validate_copy_link_path(source: &Path, link: &Path) -> Result<()> {
    if link.as_os_str().is_empty()
        || link.is_absolute()
        || link.components().any(|component| {
            matches!(
                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()
                );
            }
        }

View on GitHub (pinned to 533346cc37)