Repository navigation
fix: resolve symlinks in sh shims before computing basedir - #59
Conversation
POSIX shells set $0 to the path of the invoked symlink, not the shim it points at. When a shim was reached through an external symlink (for example one placed on PATH), basedir resolved to the symlink's directory and the relative target path into node_modules broke. Follow the symlink chain with readlink before deriving basedir. Fixes pnpm/pnpm#13405 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 40 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughPOSIX shim generation now follows absolute and relative symbolic links before deriving ChangesPOSIX shim resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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 |
PR Summary by QodoFix sh shim basedir by resolving $0 symlink chain before launching target
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
The .exe-target sh shim snapshot is only exercised on Windows, so the Linux snapshot regeneration could not update it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The cap makes a symlink cycle rewritten mid-execution terminate instead of looping forever. New e2e tests cover relative-target hops (the dirname-composition branch), directories with spaces, and a node-shebang bin invoked through a chain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The cap makes a symlink cycle rewritten mid-execution terminate instead of looping forever, mirroring the kernel's ELOOP limit. The regression tests now route the chain through a relative symlink in another directory, covering the shim's dirname-composition branch that the absolute-only chain missed. Applied identically to the Rust template and the `@zkochan/cmd-shim` patch, matching upstream pnpm/cmd-shim#59. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The symlink-resolution fix is released upstream (pnpm/cmd-shim#59), so the patchedDependencies entry is no longer needed and library consumers of the TypeScript packages get the fixed shims too. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
POSIX shells set
$0to the path of the invoked symlink, not the shim it points at. When a generated sh shim is reached through an external symlink (for example one placed onPATH),basedirresolved to the symlink's directory, so the relative target path intonode_modulesbroke and the shim failed to launch its target.This follows the symlink chain with a portable
readlinkloop before derivingbasedir. Note that npm'scmd-shimdoes not need this because npm links POSIX bins as plain symlinks rather than sh shims; pnpm relies on sh shims on POSIX, so the shim itself has to resolve its physical location.Fixes pnpm/pnpm#13405. The same change already ships in pnpm via a
patchedDependenciespatch on@zkochan/cmd-shim@9.0.6(pnpm/pnpm#13411, mirroring the Rustpacquet-cmd-shimtemplate); releasing this upstream lets that patch be dropped.Tests
linking to another drive on Windowsentries were restored by hand (Node's snapshot updater drops entries not exercised on the running platform) with the same header change applied.Written by an agent (Claude Code, claude-fable-5).
Summary by CodeRabbit