Repository navigation
fix(npm): stop npm view from re-entering mise through a foreign shim - #14084
Conversation
Co-authored-by: Tim Fournet <8159901+tfournet@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M4BVDNCW6X46GY1VXS4AERHB
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughUnix Changesnpm shell-out resolution
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to No concrete issue remains that should prevent merging after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M4BVRDHWF61F9C2MM8X4VJCC
…entry Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M4BVZZV2N5DG8XTHQTAPWT09
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M4BW9Z4RD402QB8PSPHG1PR1
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2266bc4. Configure here.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M4BWQV8PS3Z2EVR5CDFRFXKC
<!-- entire-trail-link-start --> https://entire.io/gh/jdx/mise/trails/512 <!-- entire-trail-link-end --> When an unconfigured Unix shim falls back to a system wrapper that execs the bare command name again, the wrapper can re-enter the shim indefinitely. Mise now rejects a repeated `(command name, canonical fallback path)` handoff in the same PID with an error telling the user to set a version or remove the shim. Addresses [discussion #14086](#14086), as a follow-up to #14084's separate npm backend fix. Based on @alleneubank's proposed PID-owned fallback chain, with co-author credit. A child process starts a fresh chain, so legitimate nested calls such as `bun run` invoking `bun` remain valid. Distinct wrappers can form a finite chain, with a 32-handoff safety limit. Configured tools and command wrappers clear the chain. Recording happens only after the final lookup, including any `auto_update` lookup, and the serialized paths retain their exact bytes. This guard covers Unix symlink-shim fallback through same-process `exec` chains. It does not bound cycles that spawn new child processes or change Windows shim dispatch. Validation on macOS: - Six focused unit tests pass. - The new e2e regression fails against released 2026.10.4 and passes with the patch. It covers normal and relocated shims, a 12-wrapper finite chain, legitimate child-process nesting, and clearing state on configured-wrapper resolution, including templated early settings. - Four existing shim/exec regression tests pass. - `cargo check --all-features`, strict workspace Clippy, formatting, ShellCheck, and shfmt pass. hk's Cargo step denies existing manifest warnings (redundant homepage and unused optional OpenSSL dependency), so that step was skipped in the scoped hk run and Cargo was checked directly. *AI-assisted — Tool: Codex; model: openai/unavailable; version: unavailable.* <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core Unix shim dispatch and system-fallback behavior; mistakes could block legitimate wrapper chains or fail to stop infinite loops. > > **Overview** > On Unix, when an unconfigured shim uses **system fallback** and the resolved binary is a wrapper that `exec`s the same command name again, mise could loop indefinitely. This PR adds a **PID-scoped fallback chain** (`__MISE_SHIM_FALLBACK_CHAIN`) that records each `(command name, canonical fallback path)` handoff and **bails** if the same pair repeats, with a **32-handoff** cap and guidance to set a version or remove the shim. > > Shim resolution is refactored to return a **`ShimCommand`** (`Tool`, `Wrapper`, or `SystemFallback`); only **system fallback** paths extend the chain after the final lookup (including post-`auto_update` re-resolve). Entering a configured tool or command wrapper **clears** inherited chain state so wrappers do not leak across resolutions. Child processes get a fresh chain, so patterns like a wrapper spawning the same name remain valid. > > A new **e2e** fixture covers recursion rejection (normal and relocated shims), finite multi-wrapper chains, legitimate nested child calls, and chain reset when a configured wrapper runs. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9c5ac01. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * CLI shim fallback now reports an error when fallback resolution recurses, instead of continuing until a hop limit is reached. * Finite fallback chains of up to 12 distinct shims complete successfully. * Recursive shim calls from child processes work as expected, and resolving a configured command wrapper clears inherited fallback state. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Allen Eubank <alleneubank@users.noreply.github.com>
Instruction countsNothing was compared, and so nothing was gated. No series appears on both sides: either the base has no measurements recorded, or the two were measured on different runner classes, which are deliberately not comparable — counts shift between machine types by more than a real regression does. New, nothing to compare against: Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.
|
<!-- entire-trail-link-start --> https://entire.io/gh/jdx/mise/trails/493 <!-- entire-trail-link-end --> ### 🚀 Features - **(bootstrap)** add an os filter to files and directories by @jdx in [#14058](#14058) - **(bootstrap)** add auto mode for fish shell activation by @jdx in [#14172](#14172) - **(config)** merge [bootstrap] from config includes by @jdx in [#14176](#14176) - **(doctor)** show dotfiles repo path and origin by @jdx in [#14173](#14173) - **(dotfiles)** give each machine its own tracked version with a machine variant by @jdx in [#14062](#14062) - **(dotfiles)** infer merge sources and keep app state when switching from symlink by @jdx in [#14076](#14076) - **(dotfiles)** add merge = "missing" to fill in defaults the app may change by @jdx in [#14081](#14081) - **(dotfiles)** add track-local for history that never leaves the machine by @jdx in [#14082](#14082) - **(dotfiles)** refuse to publish saved versions that look like secrets by @jdx in [#14171](#14171) - **(installs)** move installs that cannot be reinstalled into the identity layout during migrate by @jdx in [#14079](#14079) - **(java)** **breaking** default java versions to Temurin builds by @jdx in [#14146](#14146) - **(mcp)** implement install_tool and require a trusted project for run_task by @jdx in [#14111](#14111) - **(packslip)** add a workflow option to pin the signing workflow by @jdx in [#14075](#14075) - **(packslip)** accept a list of signing workflows by @jdx in [#14093](#14093) ### 🐛 Bug Fixes - **(backend)** respect disable_backends in ls-remote by @jdx in [#14130](#14130) - **(bootstrap)** keep applying other package managers after one fails by @jdx in [#14138](#14138) - **(bootstrap)** skip the firewall section where it is unsupported by @jdx in [#14137](#14137) - **(bootstrap)** keep shell activation when a dotfile is tracked by @jdx in [#14135](#14135) - **(bootstrap)** warn on legacy command spellings and mise direnv by @jdx in [#14113](#14113) - **(bootstrap)** show hooks that use exec() in dry runs by @jdx in [#14136](#14136) - **(bootstrap)** support absent and unapply for systemd units by @jdx in [#14139](#14139) - **(brew)** infer formula version from the GitHub release tag path by @JamBalaya56562 in [#14165](#14165) - **(brew)** detach a DMG left attached by an interrupted install by @jdx in [#14177](#14177) - **(cargo)** do not resolve dependencies to mise shims by @jdx in [#14070](#14070) - **(cli)** accept yes/no booleans, prefix: in latest, and warn log level by @jdx in [#14125](#14125) - **(cli)** print the invoked command name in help by @jdx in [#14123](#14123) - **(cli)** replace unimplemented!() in --monorepo flags with an error by @jdx in [#14116](#14116) - **(config)** report an invalid tool version in config ls instead of panicking by @JamBalaya56562 in [#14094](#14094) - **(config)** verify .monorepo markers in paranoid mode by @jdx in [#14105](#14105) - **(config)** apply config environment files in directory order by @jdx in [#14148](#14148) - **(config)** ignore project bootstrap and dotfiles config in safe mode by @jdx in [#14110](#14110) - **(daemons)** quote deferred daemon commands for cmd.exe on Windows by @JamBalaya56562 in [#14055](#14055) - **(daemons)** run argv and Windows readiness probes in the tool environment by @JamBalaya56562 in [#14080](#14080) - **(doctor)** recognize a `mise` entry in the dedicated shims dir by @jdx in [#14069](#14069) - **(dotfiles)** say when incoming history changes no files on this machine by @jdx in [#14066](#14066) - **(dotfiles)** let MISE_YES confirm rollback, undo, and recover by @jdx in [#14067](#14067) - **(dotfiles)** save files replaced when adopting a setup, and add --take-remote-all by @jdx in [#14065](#14065) - **(dotfiles)** don't require --yes without a TTY for recoverable confirmations by @jdx in [#14071](#14071) - **(dotfiles)** stop prompting for recoverable operations by @jdx in [#14077](#14077) - **(edit)** do not overwrite an existing config without a terminal by @jdx in [#14124](#14124) - **(env)** honor redact = false exclusions in mise env --redacted by @jdx in [#14109](#14109) - **(env)** skip watch_files runs in safe mode and with --no-hooks by @jdx in [#14108](#14108) - **(exec)** install exact versions when the version list times out by @jdx in [#14164](#14164) - **(generate)** update the GitHub Actions and devcontainer templates by @jdx in [#14145](#14145) - **(generate)** skip hidden and global tasks in task-stubs by @jdx in [#14127](#14127) - **(github)** check asset size without a checksum by @jdx in [#14128](#14128) - **(github)** percent-encode the tag in gitlab release lookups by @thespags in [#14102](#14102) - **(java)** key the version cache by vendor and keep release_type by @jdx in [#14131](#14131) - **(migrate)** keep an unwritable stderr from aborting mise during a migration by @JamBalaya56562 in [#14158](#14158) - **(node)** verify GPG signatures for every node version by @jdx in [#14132](#14132) - **(npm)** stop npm view from re-entering mise through a foreign shim by @jdx in [#14084](#14084) - **(packslip)** let a user signer option replace a registry workflow default by @jdx in [#14091](#14091) - **(plugins)** install git:: plugins from a subdirectory by @jdx in [#14140](#14140) - **(plugins)** install packslip entries in [plugins] as vfox plugins by @jdx in [#14141](#14141) - **(plugins)** stop mise plugins uninstall --purge from panicking by @jdx in [#14117](#14117) - **(plugins)** install and compare git:: subdirectory sources from [plugins] by @onokonem in [#14150](#14150) - **(prune)** skip a tracked config whose tool version no longer parses by @JamBalaya56562 in [#14103](#14103) - **(ruby)** expand {os} and {arch} in precompiled URLs correctly by @jdx in [#14133](#14133) - **(sandbox)** clear inherited variables for --deny-env on Windows by @jdx in [#14107](#14107) - **(sandbox)** reject allow_net on macOS instead of writing invalid rules by @jdx in [#14106](#14106) - **(settings)** reject settings set in places mise ignores them by @jdx in [#14126](#14126) - **(shim)** skip version lookups for lazy tools that are not installed by @jdx in [#14063](#14063) - **(shim)** stop system fallback cycles through wrappers by @jdx in [#14088](#14088) - **(shim)** match Windows lazy shim names regardless of ASCII case by @jdx in [#14090](#14090) - **(spm)** use a custom api_url for cloning and skip lockfile URLs by @jdx in [#14129](#14129) - **(task)** report unmatched sources, show depends_post, and load global tasks by @jdx in [#14122](#14122) - **(task)** resolve mise run ./script relative to the current directory by @jdx in [#14120](#14120) - **(task)** send mbx-cache headers to the remote task cache by @jdx in [#14147](#14147) - **(task)** strip script extensions only from file task names by @jdx in [#14159](#14159) - **(task)** skip fresh raw and interactive cached tasks when their cache key is unchanged by @jdx in [#14121](#14121) - **(task)** keep secret values out of remote cache keys by @jdx in [#14104](#14104) - **(use)** create config.toml instead of writing global tools to config.<env>.toml by @jdx in [#14179](#14179) - **(vfox)** do not fail every command for an env plugin with no source by @jdx in [#14119](#14119) - **(vfox)** resolve embedded plugin files from the manifest dir by @jdx in [#14167](#14167) - **(watch)** pass watchexec flags through to watchexec by @jdx in [#14115](#14115) - keep temporary files out of the cache directory by @jdx in [#14134](#14134) - point error hints at current commands by @jdx in [#14142](#14142) - replace panics on bad input with errors by @jdx in [#14118](#14118) - require experimental for remote task sources, OpenTelemetry and spinel by @jdx in [#14114](#14114) ### 📚 Documentation - **(agents)** treat 12 months as the default deprecation window by @jdx in [#14100](#14100) - **(cli)** hide mise bootstrap dotfiles and mise tasks run from help by @jdx in [#14101](#14101) - restructure and rewrite the documentation site by @jdx in [#14097](#14097) - rewrite CLI help and settings descriptions by @jdx in [#14098](#14098) - update pages for behavior changed by recent fixes by @jdx in [#14163](#14163) ### 🧪 Testing - **(backend)** give test_ubi a longer version-fetch timeout by @jdx in [#14162](#14162) - **(config)** don't rely on teleport plugins being absent in not-found test by @jdx in [#14059](#14059) - **(windows)** isolate install fixtures and wait for executable teardown by @jdx in [#14089](#14089) ### 📦️ Dependency Updates - update rust crate demand to v2.4.0 by @renovate[bot] in [#14054](#14054) - update aube to v2.7.0 by @renovate[bot] in [#14074](#14074) ### 📦 Registry - pin packslip tools to the workflow that signs their releases by @jdx in [#14092](#14092) - rename mprocs to dekit and keep mprocs as an alias by @jdx in [#14169](#14169) ### Chore - **(docs)** keep moved pages reachable and fail on dead anchors by @jdx in [#14096](#14096) - **(settings)** deprecate settings that have no effect by @jdx in [#14112](#14112) - run e2e tests from mise run test and fix the registry test example by @jdx in [#14143](#14143) ### Ci - install mold from its GitHub release instead of apt by @jdx in [#14085](#14085) - stop installing direnv for the e2e tests by @jdx in [#14170](#14170) ### Security - **(http)** redact URL credentials in debug logs by @jdx in [#14155](#14155) - **(npm)** redact credentials in Git-source diagnostics by @jdx in [#14057](#14057) - **(npm)** redact normalized SSH diagnostics by @jdx in [#14064](#14064) - **(worktrunk)** pin the registry default to the release workflow on tags by @max-sixty in [#14073](#14073) ### New Contributors - @onokonem made their first contribution in [#14150](#14150) - @max-sixty made their first contribution in [#14073](#14073) ## 📦 Aqua Registry Updates ### Updated Packages (2) - [`charmbracelet/skate`](https://github.com/charmbracelet/skate) - [`pvolok/dekit`](https://github.com/pvolok/dekit)

https://entire.io/gh/jdx/mise/trails/510
Fixes #14068. Recreates #14072 by @tfournet, who found and fixed the bug.
With
npm.shell_out,mise latest npm:<pkg>could run a mise shim from another data dir asnpm. That happens when an outer mise's shims are onPATHwhileHOMEorMISE_DATA_DIRpoint elsewhere, as in test runners and CI. The shim re-entered mise, which rannpm viewagain for everylatestnpm tool. The process count grew at every level until the machine ran out of memory.npm viewnow resolvesnpmfrom the childPATHitself and skips any candidate that is the running mise binary. If a mise shim was the only npm, mise stops with an error instead of spawning it:If a real npm exists later on
PATH, it is used. If there is no npm at all, the behavior and error are unchanged. Windows is unchanged.Changes from #14072:
file::same_filecompares paths, so it missed hard links.PATHentry resolves to an absolute path. A barenpmmade the child searchPATHagain and find the shim that was just skipped.npmis no longer picked over a real npm later onPATH.RLIMIT_NPROCcounts them. It is also no longer executable, as the repo requires.Unit tests cover the foreign shim, shim-only, no-npm, hard-link, directory and empty-entry cases.
e2e/backend/test_npm_shell_out_foreign_shimfails with a fork storm without the fix and passes with it.AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: claude-code_2-1-289_agent.
🤖 Generated with Claude Code
Note
Medium Risk
Changes how npm is resolved for shell-out metadata lookups on Unix; wrong detection could block valid npm or still recurse, but scope is limited to npm.shell_out and includes regression tests.
Overview
Fixes a fork storm when
npm.shell_outis on and a foreign mise shim (e.g. another install’s shims onPATHwhileHOME/MISE_DATA_DIRdiffer) is the firstnpmon the childPATH.mise latest npm:*could re-enter mise and repeatnpm viewfor every tool (#14068).On Unix,
npm viewnow picks the executable explicitly from the dependencyPATH: skip known mise shim directories, treat symlink/hard-link copies of the runningmisebinary as shims, resolve empty/relativePATHentries to absolute paths, and ignore a directory namednpm. If only a mise shim remains, mise errors with a clear message instead of spawning it; a realnpmlater onPATHis used; missingnpmbehavior is unchanged. Windows still uses the prior spawn path. Thenpm viewinvocation also setsNPM_CONFIG_UPDATE_NOTIFIER=false.Adds unit tests for shim skipping, hard links, empty
PATH, and dirs namednpm, plus an e2e regression with an outernpmshim and a process cap so a recurrence fails fast.Reviewed by Cursor Bugbot for commit e8dcb2c. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit