Repository navigation
feat: create pnpx for bundled pnpm - #8241
Merged
Merged
Conversation
Member
|
This will work. Alternatively, we could also just update the shell config files and add aliases. We already update the shell config files in order to extend the PATH env variable. |
Contributor
Author
It wouldn't work on Windows Command Prompt though. And I don't know how PowerShell's version of rc file works. |
Contributor
Author
Also, this definitely wouldn't work in CI environment. |
Member
|
OK, add a comment about it to the function. Why this approach instead of aliases. |
zkochan
approved these changes
Jun 26, 2024
zkochan
pushed a commit
that referenced
this pull request
Jul 5, 2024
4 tasks done
zkochan
added a commit
that referenced
this pull request
Sep 14, 2026
…14797) The alias bins looked pnpm up on PATH, so the pnpm that ran was whichever one PATH named first. That failed where the directory holding them was not on PATH, even with the native binary sitting next to them, and it let any other pnpm ahead of that directory silently handle calls meant for the local install. Every form now names its sibling. The POSIX script walks `$0` through its symlinks and execs the pnpm in that directory; the walk matters because `$0` is the shim or symlink the alias was launched through, and the sibling to find is the one in the package, not in whichever directory linked it. Its hop cap matches the `pnpm` placeholder script, which walks `$0` for the same reason. The `.cmd` calls "%~dp0pnpm.cmd" with `call`, so control returns and the exit code is the shim's; the `.ps1` calls "$basedir\pnpm.ps1" and ends in `exit $LastExitCode`, which it dropped before. The Windows wrappers have one sibling to name because `pnpm setup` installs via `pnpm add -g` and link_bins writes a bare pnpm.exe only for the `node` bin name, so every other bin gets the pnpm/pnpm.cmd/pnpm.ps1 shim trio. Only the v12 tarball regressed. The v11 `pnpm` package's bins are real entry points that resolve relative to themselves, and v12 replaced them with these scripts. The other three writers have always been PATH-based: `pnpm setup` in both stacks since #8241, and `@pnpm/exe`'s prepare.js. All four change here, which puts the fix in both stacks as the version policy requires. Two asymmetries are deliberate. `@pnpm/exe`'s POSIX aliases also check that the sibling is executable, because the placeholder its install script replaces is not, and the EACCES from exec'ing that placeholder would say nothing about the script having been skipped. Its .cmd and .ps1 stay on PATH, because that same install script hardlinks the binary onto pn.exe/pnpx.exe/pnx.exe and points `bin` at them, so those wrappers only run when it did not — and then there is no sibling to resolve. Closes #14803. --------- Co-authored-by: Zoltan Kochan <[email protected]>
biisal
pushed a commit
to biisal/pnpm
that referenced
this pull request
Sep 15, 2026
…npm#14797) The alias bins looked pnpm up on PATH, so the pnpm that ran was whichever one PATH named first. That failed where the directory holding them was not on PATH, even with the native binary sitting next to them, and it let any other pnpm ahead of that directory silently handle calls meant for the local install. Every form now names its sibling. The POSIX script walks `$0` through its symlinks and execs the pnpm in that directory; the walk matters because `$0` is the shim or symlink the alias was launched through, and the sibling to find is the one in the package, not in whichever directory linked it. Its hop cap matches the `pnpm` placeholder script, which walks `$0` for the same reason. The `.cmd` calls "%~dp0pnpm.cmd" with `call`, so control returns and the exit code is the shim's; the `.ps1` calls "$basedir\pnpm.ps1" and ends in `exit $LastExitCode`, which it dropped before. The Windows wrappers have one sibling to name because `pnpm setup` installs via `pnpm add -g` and link_bins writes a bare pnpm.exe only for the `node` bin name, so every other bin gets the pnpm/pnpm.cmd/pnpm.ps1 shim trio. Only the v12 tarball regressed. The v11 `pnpm` package's bins are real entry points that resolve relative to themselves, and v12 replaced them with these scripts. The other three writers have always been PATH-based: `pnpm setup` in both stacks since pnpm#8241, and `@pnpm/exe`'s prepare.js. All four change here, which puts the fix in both stacks as the version policy requires. Two asymmetries are deliberate. `@pnpm/exe`'s POSIX aliases also check that the sibling is executable, because the placeholder its install script replaces is not, and the EACCES from exec'ing that placeholder would say nothing about the script having been skipped. Its .cmd and .ps1 stay on PATH, because that same install script hardlinks the binary onto pn.exe/pnpx.exe/pnx.exe and points `bin` at them, so those wrappers only run when it did not — and then there is no sibling to resolve. Closes pnpm#14803. --------- Co-authored-by: Zoltan Kochan <[email protected]>
u9g
pushed a commit
to u9g/pnpm
that referenced
this pull request
Sep 25, 2026
…npm#14797) The alias bins looked pnpm up on PATH, so the pnpm that ran was whichever one PATH named first. That failed where the directory holding them was not on PATH, even with the native binary sitting next to them, and it let any other pnpm ahead of that directory silently handle calls meant for the local install. Every form now names its sibling. The POSIX script walks `$0` through its symlinks and execs the pnpm in that directory; the walk matters because `$0` is the shim or symlink the alias was launched through, and the sibling to find is the one in the package, not in whichever directory linked it. Its hop cap matches the `pnpm` placeholder script, which walks `$0` for the same reason. The `.cmd` calls "%~dp0pnpm.cmd" with `call`, so control returns and the exit code is the shim's; the `.ps1` calls "$basedir\pnpm.ps1" and ends in `exit $LastExitCode`, which it dropped before. The Windows wrappers have one sibling to name because `pnpm setup` installs via `pnpm add -g` and link_bins writes a bare pnpm.exe only for the `node` bin name, so every other bin gets the pnpm/pnpm.cmd/pnpm.ps1 shim trio. Only the v12 tarball regressed. The v11 `pnpm` package's bins are real entry points that resolve relative to themselves, and v12 replaced them with these scripts. The other three writers have always been PATH-based: `pnpm setup` in both stacks since pnpm#8241, and `@pnpm/exe`'s prepare.js. All four change here, which puts the fix in both stacks as the version policy requires. Two asymmetries are deliberate. `@pnpm/exe`'s POSIX aliases also check that the sibling is executable, because the placeholder its install script replaces is not, and the EACCES from exec'ing that placeholder would say nothing about the script having been skipped. Its .cmd and .ps1 stay on PATH, because that same install script hardlinks the binary onto pn.exe/pnpx.exe/pnx.exe and points `bin` at them, so those wrappers only run when it did not — and then there is no sibling to resolve. Closes pnpm#14803. --------- Co-authored-by: Zoltan Kochan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #8230