Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpm doesn't add binary to node_modules/.bin if bin command is prefixed (@prefix/package-name) #7112

Closed
2 of 4 tasks
marvinjude opened this issue Sep 19, 2023 · 2 comments · Fixed by #7237
Closed
2 of 4 tasks

Comments

@marvinjude
Copy link

marvinjude commented Sep 19, 2023

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.6.0

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

https://github.com/marvinjude/prefixed-package-bin-issue

Reproduction steps

pnpm install

Describe the Bug

If a package @prefix/package-name ships with a bin field like so:

"bin": {
  "@prefix/package-name": "./somefile"
}

After an install, one would expect that pnpm would add the binary package-name to node_modules/.bin(just like in npm, bun and yarn v2) but that doesn't happen. Doing a pnpm patch on such a package and changing the command to "package-name" without the prefix gets it to work. Another typical fix for this on the package author's end would be to change the above bin configuration to

"bin":  "./somefile"

Expected Behavior

pnpm should add binary to node_modules/.bin for packages with prefixed commands like the below:

"bin": {
  "@prefix/package-name": "./somefile"
}

so that you can run pnpm exec package-name.

Happy to work on this with some directions if the team considers this a bug

Which Node.js version are you using?

18.17.1

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@marvinjude marvinjude changed the title pnpm doesn't add binary to node_modules/.bin if package is prefixed (@prefix/package-name) pnpm doesn't add binary to node_modules/.bin if bin command is prefixed (@prefix/package-name) Sep 19, 2023
@cdaringe
Copy link

i think this is undefined behavior as specified by npm, which pnpm attempts some amount of compliance: https://docs.npmjs.com/cli/v6/configuring-npm/package-json#bin

i personally wouldn't label it as a bug, as it violates some norms:

  • @ in the executable--do you really want an executable with a @ in it? fwiw, npm installs an executable just called ui.
  • / in the executable--what would that produce? a subfolder in bin? if that's the case, .bin/ housing executables would be an implicit violation of expectations

albeit the current behavior of doing nothing is agreeably not ideal (a warning perhaps would be warranted), expecting a bin name of that to work is also subjectively not a fair/reasonable expectation either.

i'd change the bin name to ui to proceed. maybe add logging/warns to this case during the bin linking

@marvinjude
Copy link
Author

marvinjude commented Sep 19, 2023

Yeah, a warning is definitely a great idea, I'd say, a great example for other package managers.

Along with the warning, It makes sense for pnpm to also maintain a behavior that exists in other major package managers - yarn(v2), bun, and npm - in this case adding ui and not just bail out.

And yeah! we may not explicitly label this a bug, maybe a compatibility / feature request is more ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants