oven-sh / bun

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

Bun install --force cannot remap bun binarys after remove bun #11319

Open Huliiiiii opened 1 month ago

Huliiiiii commented 1 month ago

What version of Bun is running?

1.1.9+bb13798d9

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

"scripts": {
    "format": "prettier --write ./src",
    "commit": "bun run format && git cz"
}
  1. bun add bun
  2. bun install --force
  3. bun run commit => success
  4. bun rm bun
  5. bun install --force
  6. bun run commit =>
    
    $ bun run format && git cz
    error: bin executable does not exist on disk

Bun failed to remap this bin to its proper location within node_modules. This is an indication of a corrupted node_modules directory.

Please run 'bun install --force' in the project root and try it again. If this message persists, please open an issue: https://github.com/oven-sh/bun/issues

error: script "commit" exited with code 255


8. remove bun binarys in node_modules/.bin
9. bun run commit => success

### What is the expected behavior?

1. bun add bun
2. bun install --force
3. bun run commit => success
4. bun rm bun
5. bun install --force
6. bun run commit => success

### What do you see instead?

_No response_

### Additional information

_No response_
lukewlms commented 1 month ago

We have most of our scripts starting with "bunx" now to work with bun install. That's what seems to work.

I'm guessing if this is your format script, it will work on Windows (Mac/Linux seem fine without specifying bunx - I'd be interested in more detail on that since this seems like an obscure error).

"bunx prettier --write ./src"

doreenhuang57 commented 1 month ago

I'm also on Windows and encountered the same issue with our scripts, in addition to "bunx" we found that the "--bun" flag was needed at times as well.

For prettier, bunx --bun prettier --write ./src should work.