jdx/mise · error

recursive shim invocation detected for

Error message

recursive shim invocation detected for {bin_name}: {}

What it means

`handle_shim` records the current shim path in `MISE_SHIM_PATH` and detects when a shim resolves to a binary that is itself the same shim (via canonicalized path comparison of previous invocation and current shim path). When recursion is detected, mise bails instead of looping forever or overflowing the stack.

Solutions

  1. Inspect PATH: `echo $PATH | tr ':' '\n' | grep -n shims` and remove duplicate mise shims entries.
  2. Reinstall the affected tool (`mise install <tool>@<version>`) so the real binary exists and the shim resolves correctly.
  3. Delete and regenerate shims: `mise reshim` after fixing the tool install.

Example fix

// before (.zshrc)
export PATH="$HOME/.local/share/mise/shims:$HOME/.local/share/mise/shims:$PATH"
// after
export PATH="$HOME/.local/share/mise/shims:$PATH"
Defensive patterns

Strategy: try-catch

Validate before calling

echo $PATH | tr ':' '\n' | grep -c 'mise/shims'  # expect 1 occurrence

Try / catch

try {
  await $`${tool} --version`;
} catch (e) {
  if (String(e).includes('recursive shim invocation')) {
    await $`mise reshim`;
  } else throw e;
}

Prevention

When it happens

Trigger: A shim whose target binary is (or resolves to) the shim itself — e.g. a broken symlink loop, a tool binary overwritten by a copy of the shim, or `~/.local/share/mise/shims` duplicated on PATH so a tool name resolves back to mise's shim.

Common situations: Shims directory prepended twice in PATH within a deeply nested shell; an installed tool missing so PATH resolution falls through to the shim again; FS corruption or manual copying of shim files into a bin directory.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/shims.rs:118

pub(crate) async fn handle_shim() -> Result<()> {
    // TODO: instead, check if bin is in shims dir
    let bin_name = *env::MISE_BIN_NAME;
    if env::is_mise_binary(bin_name) || cfg!(test) {
        return Ok(());
    }
    #[cfg(windows)]
    {
        let shim_path = invoked_shim_path();
        if env::var_path(env::MISE_SHIM_PATH_ENV)
            .as_ref()
            .is_some_and(|previous| {
                file::paths_eq(
                    &file::canonicalize_or_self(previous),
                    &file::canonicalize_or_self(&shim_path),
                )
            })
        {
            bail!(
                "recursive shim invocation detected for {bin_name}: {}",
                display_path(&shim_path)
            );
        }
        *env::MISE_SHIM_PATH.write().unwrap() = Some(shim_path.clone());
        env::set_var(env::MISE_SHIM_PATH_ENV, &shim_path);
    }
    let mut config = Config::get().await?;
    let mut args = env::ARGS.read().unwrap().clone();
    env::PREFER_OFFLINE.store(true, Ordering::Relaxed);
    trace!("shim[{bin_name}] args: {}", args.join(" "));
    let (bin, ts, wrapper) = which_shim(&mut config, &env::MISE_BIN_NAME, &args).await?;
    args[0] = bin.to_string_lossy().to_string();
    if let Some(wrapper) = &wrapper {
        args.splice(1..1, wrapper.args().iter().cloned());
    }
    env::set_var("__MISE_SHIM", "1");
    let exec = Exec {

View on GitHub (pinned to 533346cc37)