jdx/mise · error · eyre::Report

rename_exe: cannot rename '{}' to '{}': target already exist

Error message

rename_exe: cannot rename '{}' to '{}': target already exists. Check for duplicate or overlapping rename_exe mappings.

What it means

During install, mise applies `rename_exe` mappings by renaming a file inside the install dir; finish_rename refuses to overwrite an existing target. The collision means two mappings point at the same name, or the archive already contains a file with that name — silently dropping one would lose a binary, so the install fails loudly (src/backend/static_helpers.rs:1169).

Source

Thrown at src/backend/static_helpers.rs:1169

}

/// Renames `path` (named `file_name`) to `target` within `dir`, preserving any
/// required extension and ensuring the result is executable. A collision on the
/// target (two mappings pointing at the same name, or the archive already
/// containing that name) is unsatisfiable, so it fails the install loudly rather
/// than silently dropping a binary and reporting success.
fn finish_rename(dir: &Path, path: &Path, file_name: &str, target: &str) -> eyre::Result<()> {
    let target_path = keep_required_extensions(dir, file_name, target, dir.join(target));
    // Ensure the binary is executable whether or not we move it: ZIP archives drop
    // the exec bit, and the file may already carry the desired name.
    if !file::is_executable(path) {
        file::make_executable(path)?;
    }
    if path == target_path {
        return Ok(());
    }
    if target_path.exists() {
        bail!(
            "rename_exe: cannot rename '{}' to '{}': target already exists. \
             Check for duplicate or overlapping rename_exe mappings.",
            path.display(),
            target_path.display()
        );
    }
    file::rename(path, &target_path)?;
    debug!("Renamed {} to {}", path.display(), target_path.display());
    Ok(())
}

/// Helper function to rename executable inside a macOS .app bundle
fn rename_executable_in_app_bundle(
    macos_dir: &Path,
    target_path: &Path,
    tool_name: Option<&str>,
) -> eyre::Result<bool> {
    // Find the first executable in the Contents/MacOS directory

View on GitHub (pinned to 9dcfcaa0dc)

Solutions

  1. List your rename_exe mappings and make every target name unique, e.g. tool-linux -> "tool-linux" and tool-macos -> "tool-macos"
  2. If the archive already contains a file named as the target, drop that mapping — no rename is needed
  3. Check that one mapping's target is not another mapping's source (chained renames overlap)

Example fix

# before (mise.toml)
[tools]
mytool = { ..., rename_exe = { 'tool-linux' = 'tool', 'tool-linux-arm' = 'tool' } }

# after
[tools]
mytool = { ..., rename_exe = { 'tool-linux' = 'tool-linux', 'tool-linux-arm' = 'tool-linux-arm' } }
Defensive patterns

Strategy: validation

Validate before calling

# Bash/Rust-side preflight: reject duplicate rename targets
# values: the rename_exe map from mise.toml
fn unique_targets_ok(map: &std::collections::BTreeMap<String, String>) -> bool {
    let mut seen = std::collections::BTreeSet::new();
    map.values().all(|t| seen.insert(t.clone()))
}
assert!(unique_targets_ok(&[("a".into(), "x".into()), ("b".into(), "y".into())].into_iter().collect()));
assert!(!unique_targets_ok(&[("a".into(), "x".into()), ("b".into(), "x".into())].into_iter().collect()));

Prevention

When it happens

Trigger: Two entries in a rename_exe map resolving to the same target name (e.g. both `tool-linux = "tool"` and `tool64 = "tool"` for one platform), or a rename target that already exists verbatim in the extracted archive, or an overlapping mapping where the source of one rename is the target of another.

Common situations: Copy-pasted rename_exe tables where the per-platform keys were changed but targets were not; archives that already ship a launcher with the generic name you renamed to; Windows extension handling (.exe) making two names collide after extension preservation.

Related errors


AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17). Data as JSON: /api/errors/b47fcfe030d67cd0. Report an issue: GitHub.