Repository navigation
fix: keep npm and npx shims working for symlinked tool binaries - #3230
Conversation
Hard-linking a symlinked target copied the relative link into the tools bin dir, where it dangled (e.g. npm/npx from nodejs). Point the shim at the target's absolute path instead so the executable keeps its package layout. Fixes #3229
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
yohamta0
left a comment
There was a problem hiding this comment.
Thanks @RyoKusnadi, nice catch on the hardlink following (or not following) the symlink. This fixes corepack too. LGTM!
Summary
npmandnpxwere not found after installingnodejs/nodethroughtools. The shims in the tools bin dir were dangling symlinks.Changes
createShimFilewhen the target is itself a symlink, and point the shim at the target's absolute path instead.link(2)does not follow symlinks on Linux, so the old code copied node's relativenpm -> ../lib/node_modules/npm/bin/npm-cli.jslink into the bin dir, where it dangled.Related Issues
Closes #3229
Checklist
Tested with
go test ./internal/tools/....Summary by cubic
Fixes
npmandnpxnot being found after installingnodejs/nodethrough tools, caused by dangling shims in the bin dir.Hard-linking a symlinked target copied the relative link (e.g.
npm -> ../lib/node_modules/npm/bin/npm-cli.js) into the bin dir, where it dangled. Shims now point at the target's absolute path when the target is a symlink, and dangling shims from earlier installs are replaced on the next install. Added a test covering both behaviors. Closes #3229.Written for commit 136f4db. Summary will update on new commits.
Summary by CodeRabbit