oven-sh / bun

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

`bun completions` in a startup script causes BrokenPipe #2977

Open halostatue opened 1 year ago

halostatue commented 1 year ago

What version of Bun is running?

0.6.2

What platform is your computer?

Darwin 22.4.0 arm64 arm

What steps can reproduce the bug?

I’m using fish as my shell, so I have the following in my ~/.config/fish/config.fish file:

if test -x $HOME/.bun/bin/bun
    if ! set --global --query BUN_INSTALL
        set --global --export BUN_INSTALL $HOME/.bun
    end

    if ! contains $HOME/.bun/bin $PATH && ! contains $HOME/.bun/bin $fish_user_paths
        fish_add_path --path $HOME/.bun/bin
    end

    if ! test -s completions/bun.fish
        bun completions
    end
end

If I ensure that ~/.config/fish/completions/bun.fish is missing, then I get a crash like this on every command execution:

error: BrokenPipe

----- bun meta -----
Bun v0.6.2 (8d90d795) macOS Silicon 22.4.0
Unknown:
Elapsed: 5ms | User: 1ms | Sys: 1ms
RSS: 3.74MB | Peak: 3.74MB | Commit: 0B  | Faults: 28
----- bun meta -----

0   0x104e00de0 WTFGetBacktrace

Crash report saved to:
  ~/.bun/.bun-crash/v0.6.2-1684639802784.crash

Search GitHub issues https://bun.sh/issues or ask for #help in https://bun.sh/discord

If I run bun completions on the command line (fully interactive), I do not get this error (which will also prevent the error, but that is only because bun completions is not running without an stty). This may be related to my use of an asynchronous fish shell prompt, but bun completions should not be crashing. The crash happens before the file gets written.

What is the expected behavior?

Bun should not crash.

What do you see instead?

Bun crashes.

Additional information

With feature request #2978 (it will be filed after this issue is filed and I will backfill it), this should not be an issue.

NyllRE commented 9 months ago

bun isn't working on fish shell since may of 2023, this should be fixed