{"record":{"id":"8b627bfa9207b716","repo":"jdx/mise","slug":"command-wrapper-for-shim-name-cannot-delegate-to","errorCode":null,"errorMessage":"command wrapper for {shim_name} cannot delegate to itself","messagePattern":"command wrapper for (.+?) cannot delegate to itself","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/shims.rs","lineNumber":236,"sourceCode":"        .with_resolve_options(resolve_options)\n        .build(config)\n        .await?;\n    let wrappers = load_command_wrappers(\n        &config.config_files,\n        ts.versions.values().flat_map(|versions| &versions.requests),\n    )?;\n    validate_wrapper_names(wrappers.keys())?;\n    let wrapper = if cfg!(macos) {\n        wrappers\n            .iter()\n            .find(|(name, _)| command_names_eq(name, shim_name))\n            .map(|(_, wrapper)| wrapper)\n    } else {\n        wrappers.get(shim_name)\n    };\n    if let Some(wrapper) = wrapper {\n        if command_names_eq(wrapper.command(), shim_name) {\n            bail!(\"command wrapper for {shim_name} cannot delegate to itself\");\n        }\n        trace!(\"shim[{bin_name}] WRAPPER command: {}\", wrapper.command());\n        return Ok((PathBuf::from(wrapper.command()), ts, Some(wrapper.clone())));\n    }\n    // A configured tool may intentionally override an executable bundled by another installed\n    // tool (for example, a pinned npm overrides Node's npm). Install a missing provider declared\n    // by the registry before resolving an incidental installed provider.\n    if !completion_offline\n        && Settings::get().not_found_auto_install\n        && ts\n            .should_install_missing_registry_bin_provider(config, shim_name)\n            .await?\n    {\n        for tv in ts\n            .install_missing_bin(config, shim_name)\n            .await?\n            .unwrap_or_default()\n        {","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/shims.rs#L218-L254","documentation":"mise allows configuring command wrappers that delegate shim invocations to a different command, but a wrapper whose command equals the shim's own name would recurse infinitely. which_shim detects this self-delegation and aborts before dispatching.","triggerScenarios":"Configuring a command wrapper (in mise.toml wrapper/command-wrapper config) for tool `foo` whose resolved command is `foo` itself — e.g. `[wrapper] foo = \"foo --flag\"` or an absolute path that resolves to the same command name.","commonSituations":"Users intending to wrap a tool with extra flags but forgetting the wrapper must point at a *different* executable (or a full path to the real tool binary), so the wrapper name and target command collide.","solutions":["Point the wrapper command at the real underlying executable path (e.g. ~/.local/share/mise/installs/<tool>/.../bin/foo) instead of the bare name.","Rename the wrapper to a different command name than the target tool.","Remove the wrapper if it provides no value and call the tool directly.","Check `mise wrapper list` / relevant config to find the offending wrapper entry."],"exampleFix":"// before (mise.toml)\n[wrapper]\nnode = \"node --max-old-space-size=4096\" // delegates to itself\n\n// after\n[wrapper]\nnode = \"/home/me/.local/share/mise/installs/node/20/bin/node --max-old-space-size=4096\"","handlingStrategy":"validation","validationCode":"# bash: ensure wrapper command differs from the wrapper name before writing config\nname=\"node\"; cmd=\"node --max-old-space-size=4096\"\n[ \"$name\" = \"$(echo \"$cmd\" | awk '{print $1}')\" ] && echo \"wrapper $name delegates to itself — point it at the real binary path\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrapper commands must point at a different executable than the wrapper name.","Use absolute paths to the underlying tool binary in wrapper commands.","After editing wrappers, run the command once to verify no self-delegation error.","Name wrappers distinctly (e.g. node-heap4g) when they merely add flags."],"tags":["shims","config","recursion","rust"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}