Skip to content

fix(node): resolve symlinks in the npm shim - #15664

Merged
jdx merged 1 commit into
mainfrom
claude/mise-issue-15663-381300
Nov 12, 2026
Merged

jdx merged 1 commit into
mainfrom
claude/mise-issue-15663-381300

Conversation

@jdx

@jdx jdx commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Fixes #15663

Calling node's npm through a symlink in another directory failed, because the wrapper mise installs at bin/npm looked for node and npm next to the symlink instead of next to the install:

mise install node@26
ln -s "$(mise where node@26)/bin/npm" /usr/local/bin/npm
/usr/local/bin/npm -v
# Error: Cannot find module '/usr/local/lib/node_modules/npm/bin/npm-cli.js'

The wrapper now resolves symlinks on itself before locating the install, so the example above prints npm's version. The loop uses plain readlink, so it also works on macOS. The "Reshimming mise node..." message, which took the install name from the same path, is correct again as well.

test_node_npm_shim_slow now symlinks bin/npm into another directory and runs it from there. I ran that test and it passes; I did not run it against the old shim.

🤖 Generated with Claude Code

AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: 2.1.321.


Note

Low Risk
Narrows to the bash npm shim’s self-path resolution plus an e2e test; behavior is unchanged when npm is called directly from the install tree.

Overview
Fixes the mise npm wrapper so it still locates the Node install when bin/npm is invoked through a symlink in another directory (e.g. /usr/local/bin/npm). The shim now walks symlinks on ${BASH_SOURCE[0]} with portable readlink (no readlink -f), then derives install paths from the real script location—fixing broken npm-cli.js resolution and restoring correct reshim install naming.

E2E coverage in test_node_npm_shim_slow links bin/npm under $HOME/linked-bin and asserts npm --version succeeds via that path.

Reviewed by Cursor Bugbot for commit fd0547e. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • The npm shim now correctly handles invocation through symlinks, including links with absolute or relative targets. npm commands can therefore run when accessed through a linked path.
  • Tests
    • Added a check that invoking npm through a symlink to the installed binary returns its version.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M78VRRRGFQDTBMWH30C5XYG3
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The npm shim now resolves script symlinks before deriving its directory. An end-to-end test invokes npm through a symlink and checks that it returns a version string.

Changes: npm Shim Symlink Resolution

Layer / File(s) Summary
Resolve shim symlinks and verify invocation
src/plugins/core/assets/node_npm_shim, e2e/core/test_node_npm_shim_slow
The shim resolves absolute symlink targets directly and relative targets against the current script directory. The test invokes npm through a symlink and checks for a version string.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to fd054

This change makes the npm shim work when invoked through a symlink in another directory. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(node): resolve symlinks in the npm shim" matches the main change. The node_npm_shim asset now follows symlinks to the script before deriving this_dir, and the e2e test now symlinks bin/…
Linked Issues check Passed [#15663] The issue requires the npm wrapper to find npm-cli.js relative to the Node install when bin/npm is reached through a symlink, without readlink -f. At head, src/plugins/core/assets/node_npm_sh…
Out of Scope Changes check Passed The diff touches two files. src/plugins/core/assets/node_npm_shim contains only the symlink-resolution change that the issue requests. The e2e test change adds a symlink invocation case for that same …
Full details: Title check

Explanation

The title "fix(node): resolve symlinks in the npm shim" matches the main change. The node_npm_shim asset now follows symlinks to the script before deriving this_dir, and the e2e test now symlinks bin/npm into another directory and runs it there. The title is specific and describes the primary fix, so the check passes.

Full details: Linked Issues check

Explanation

[#15663] The issue requires the npm wrapper to find npm-cli.js relative to the Node install when bin/npm is reached through a symlink, without readlink -f. At head, src/plugins/core/assets/node_npm_shim resolves symlinks on ${BASH_SOURCE[0]} with a while [ -L ] loop using plain readlink. Absolute targets replace the path. Relative targets resolve against the directory of the current path. this_dir is then derived from the resolved file, which matches the snippet in the issue. The later pwd -P normalization and plugin_name derivation now use the resolved path, so the "Reshimming mise <name>..." message also uses the install name. The e2e test test_node_npm_shim_slow adds a symlink test in addition to the code change. No coding requirement from the issue is unmet. I did not run the test. The PR author reports a passing run.

Full details: Out of Scope Changes check

Explanation

The diff touches two files. src/plugins/core/assets/node_npm_shim contains only the symlink-resolution change that the issue requests. The e2e test change adds a symlink invocation case for that same fix, so it supports the objective. No unrelated behavior change, refactoring, or documentation change was found in the reviewed diff. The rest of the shim (should_reshim, wrap_npm_if_reshim_is_needed) is unchanged.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 132a463 and fd0547e.

Files selected for processing: 2

  • e2e/core/test_node_npm_shim_slow
  • src/plugins/core/assets/node_npm_shim

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

The npm wrapper now follows links to its own file before locating Node and npm.

  • The Node npm wrapper finds its install when called through a symlink.

No actionable issues were found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(node): resolve symlinks in the npm s..." · Reviewed by Greptile

@jdx
jdx merged commit 52aab9e into main Nov 12, 2026
55 checks passed
@jdx
jdx deleted the claude/mise-issue-15663-381300 branch November 12, 2026 23:48
@github-actions

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
env ▇▄▆█▆▅▅▁ 40,704,565 → 40,579,124 -0.31% 23.14 → 23.00ms -0.61%
hook-env █▆█▇▅▆▇▁ 43,012,142 → 42,840,542 -0.40% 23.25 → 23.51ms +1.10%
ls ▇▅█▆█▆▆▁ 45,437,936 → 45,255,105 -0.40% 25.26 → 25.13ms -0.48%
registry █▆██▇▇▇▁ 45,147,326 → 44,970,390 -0.39% 19.43 → 19.47ms +0.21%
startup ▆▆▆▇▆█▅▁ 12,763,905 → 12,702,688 -0.48% 13.35 → 12.75ms -4.47%

No instruction-count regression above 1%.

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.

fd0547ec9cfa vs 19e03e0f3299 · measured on the runner, not pushed to the history.

gabrielcosi pushed a commit to gabrielcosi/home-ops that referenced this pull request Nov 14, 2026
… (#1754)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/jdx/mise](https://github.com/jdx/mise) | patch | `2026.11.7` → `2026.11.8` |

---

### Release Notes

<details>
<summary>jdx/mise (ghcr.io/jdx/mise)</summary>

### [`v2026.11.8`](https://github.com/jdx/mise/blob/HEAD/CHANGELOG.md#2026118---2026-11-13)

[Compare Source](jdx/mise@v2026.11.7...v2026.11.8)

##### 🚀 Features

- **(bootstrap)** plan repositories and hooks in bootstrap plan by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15653](jdx/mise#15653)
- **(bootstrap)** load package manager plugins from system plugin directories by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15620](jdx/mise#15620)
- **(bootstrap)** add bootstrap settings plugins by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15621](jdx/mise#15621)
- **(bootstrap)** move macOS preferences to \[bootstrap.settings.macos] by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15622](jdx/mise#15622)
- **(config)** support block edits in bootstrap files by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15650](jdx/mise#15650)
- **(dotfiles)** warn when a copy target was edited since mise wrote it by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15600](jdx/mise#15600)
- **(github)** add versions_host_exclude to keep repos off mise-versions by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15666](jdx/mise#15666)
- **(shim)** expose the call's arguments as argv in wrapper templates by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15655](jdx/mise#15655)
- **(task)** infer root package.json scripts for npm and Bun workspaces by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15616](jdx/mise#15616)

##### 🐛 Bug Fixes

- **(activate)** skip resolving WSL Windows drive entries on PATH by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15665](jdx/mise#15665)
- **(backend)** reuse Ruby's bundled gems when installing gem: tools by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15644](jdx/mise#15644)
- **(bootstrap)** keep the brew rack lock out of the Cellar so uninstalled formulae disappear by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15597](jdx/mise#15597)
- **(bootstrap)** refuse to archive a home directory or oversized source in bootstrap remote by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15607](jdx/mise#15607)
- **(bootstrap)** build brew formulae from source in a clean environment by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15613](jdx/mise#15613)
- **(completions)** complete the next task after `:::` by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15614](jdx/mise#15614)
- **(config)** let project tool_alias override global aliases by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15615](jdx/mise#15615)
- **(config)** write \_.file for Load .env in the interactive editor by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15640](jdx/mise#15640)
- **(config)** resolve tool_alias names in minimum_release_age_excludes by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15638](jdx/mise#15638)
- **(doctor)** stop warning about the backend a packageManager checksum forces by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15604](jdx/mise#15604)
- **(env)** ignore unrelated file churn in config directories on the hook-env fast path by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15667](jdx/mise#15667)
- **(http)** hard link shared raw files on Windows instead of copying by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15647](jdx/mise#15647)
- **(lock)** send the forge token when fetching a private release's checksum file by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15637](jdx/mise#15637)
- **(lock)** error on tool arguments that match no configured tool by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15649](jdx/mise#15649)
- **(node)** resolve symlinks in the npm shim by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15664](jdx/mise#15664)
- **(npm)** find the installed digest for a tarball URL at latest in hook-env by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15643](jdx/mise#15643)
- **(pipx)** run an installed github git source with no releases offline by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15602](jdx/mise#15602)
- **(pypi)** lock the graph for the configured python and keep an existing graph on failure by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15657](jdx/mise#15657)
- **(sandbox)** allow `./` relative paths on macOS by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15599](jdx/mise#15599)
- **(spm)** record artifact bundle URLs and checksums in mise.lock by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15646](jdx/mise#15646)
- **(task)** complete bare root task names in a monorepo by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15598](jdx/mise#15598)
- **(task)** recognise --MISE and --USAGE comments in Lua file tasks by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15659](jdx/mise#15659)
- **(task)** list a task pattern's cache entries in one pass by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15671](jdx/mise#15671)
- **(uninstall)** remove the alias links of the last uninstalled version by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15605](jdx/mise#15605)
- **(vfox)** verify the lockfile checksum in locked mode by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15648](jdx/mise#15648)

##### 🚜 Refactor

- **(system)** resolve bootstrap packages once for status by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15641](jdx/mise#15641)

##### 📚 Documentation

- **(config)** clarify global_config_file does not hide \~/.config/mise from projects under home by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15639](jdx/mise#15639)
- only accept bug reports from real use by [@&#8203;jdx](https://github.com/jdx) in [e9bf531](jdx/mise@e9bf531)

##### 📦 Registry

- drop archived asdf plugin backends by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15642](jdx/mise#15642)

##### Chore

- **(ci)** run cargo-deny advisories only when dependencies change by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15601](jdx/mise#15601)

##### Ci

- email when the docs build fails on the default branch by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;15652](jdx/mise#15652)

##### 📦 Aqua Registry Updates

##### New Packages (2)

- [`cfgaudit/cfgaudit`](https://github.com/cfgaudit/cfgaudit)
- [`connectrpc/protoc-gen-connect-openapi`](https://github.com/connectrpc/protoc-gen-connect-openapi)

##### Updated Packages (8)

- [`dependabot/cli`](https://github.com/dependabot/cli)
- [`entireio/git-sync`](https://github.com/entireio/git-sync)
- [`git-bug/git-bug`](https://github.com/git-bug/git-bug)
- [`github/gh-ost`](https://github.com/github/gh-ost)
- [`helmfile/helmfile`](https://github.com/helmfile/helmfile)
- `kiro.dev/kiro-cli`
- [`matthart1983/netwatch`](https://github.com/matthart1983/netwatch)
- [`modem-dev/hunk`](https://github.com/modem-dev/hunk)

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Berlin)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yMzkuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjIzOS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.xcd.dev/gabrielcosi/home-ops/pulls/1754
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node: npm wrapper fails when bin/npm is called through a symlink

1 participant