oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.49k stars 2.79k forks source link

`bunx`/`bun exec` not working as intended with `npm:` prefix #14910

Open echoptic opened 1 month ago

echoptic commented 1 month ago

What version of Bun is running?

1.1.33+247456b67

What platform is your computer?

Linux 6.6.58_1 x86_64 unknown

What steps can reproduce the bug?

bunx npm:sv create

What is the expected behavior?

Run a package from npm and ignore locally installed executable with same name.

What do you see instead?

with bunx:

error: "git clone" for "@npm:sv" failed

error: InstallFailed cloning repository for @npm:sv
error: @npm:sv failed to resolve

with bun exec: bun: command not found: npm:sv

Additional information

If you have a program with the same name as an npm package that you try to run with npx/npm exec it will not try to download and run program from npm but it will try to run the locally installed program. I have a program called sv installed locally and when i try to run npx sv ... it doesnt run the program from npm. So I have to run it as npx npm:sv ... in order to work. When I tried running it with bunx npm:sv .../bun exec npm:sv ... I get an error.

Jarred-Sumner commented 3 weeks ago

The bug here is that we should be treating the specifiers passed as arguments the same as we do with bun add. It shouldn't be thinking that npm: is part of the name of the package, but an explicit protocol to avoid running the global sv binary