oven-sh / bun

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

`bun install -g bun` breaks bun, writes empty file to node_modules/.bin/bun.exe globally #13869

Open kisaragi-hiu opened 2 months ago

kisaragi-hiu commented 2 months ago

What version of Bun is running?

1.1.27+267afa293

What platform is your computer?

Linux 6.8.0-40-generic x86_64 x86_64

What steps can reproduce the bug?

What is the expected behavior?

Bun stays around, installing a global package does not destroy the installation.

What do you see instead?

Bun self-destructs after installing a global package.

Additional information

No response

Jarred-Sumner commented 2 months ago

This is caused by running bun install -g bun, which writes an empty bun.exe file into $PATH which somehow leads to running that version of bun instead

kisaragi-hiu commented 2 months ago

To clarify, I did not directly run bun install -g bun to trigger this. However, my global package.json (~/.bun/install/global/package.json) does turn out to have an entry for Bun, and removing it stops this behavior.

A search in my shell history showed that I did run bun install -g bun at some point (my global package.json suggests it's when 1.1.10 was latest), and that that was the last time I ran bun install -g before today.

So the error here is