bun
bun copied to clipboard
Running `bun help` in v1.1.5 from PowerShell in Windows Terminal seems to close the console handle
What version of Bun is running?
1.1.5+b257a3097
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What steps can reproduce the bug?
- Install Windows Terminal
- Open PowerShell in Windows Terminal
- Run
bun help
.
What is the expected behavior?
Help is printed, PowerShell is usable afterwards
What do you see instead?
> bun help
Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.1.5+b257a3097)
Usage: bun <command> [...flags] [...args]
Commands:
run ./my-script.ts Execute a file with Bun
lint Run a package.json script
test Run unit tests with Bun
x eslint Execute a package binary (CLI), installing if needed (bunx)
repl Start a REPL session with Bun
exec Run a shell script directly with Bun
install Install dependencies for a package.json (bun i)
add astro Add a dependency to package.json (bun a)
remove elysia Remove a dependency from package.json (bun rm)
update webpack Update outdated dependencies
link [<package>] Register or link a local npm package
unlink Unregister a local npm package
pm <subcommand> Additional package management utilities
build ./a.ts ./b.jsx Bundle TypeScript & JavaScript into a single file
init Start an empty Bun project from a blank template
create @shumai/shumai Create a new project from a template (bun c)
upgrade Upgrade to latest version of Bun.
<command> --help Print help text for command.
Learn more about Bun: https://bun.sh/docs
Join our Discord community: https://bun.sh/discord
>
An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
at System.ConsolePal.ReadKey(Boolean intercept)
at Microsoft.PowerShell.Internal.VirtualTerminal.ReadKey()
at Microsoft.PowerShell.PSConsoleReadLine.ReadOneOrMoreKeys()
at Microsoft.PowerShell.PSConsoleReadLine.ReadKeyThreadProc()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
[process exited with code 3762504530 (0xe0434352)]
You can now close this terminal with Ctrl+D, or press Enter to restart.
Additional information
Seems to reproduce both in PowerShell Core and Windows PowerShell (the built-in one), but not in cmd
, and not if PowerShell runs in conhost instead of Windows Terminal.
I can reproduce the issue running bun
or bun help
, but not bun --revision
. I'm a bit suspicious that it might be related to using VT escape sequences.
It seems as if Bun somehow frees the console handle used by PowerShell.
Also, in cmd
in both conhost and Windows Terminal, running bun help
seems to switch the console to something like a raw mode (not sure about the terminology on Windows), where keys such as arrows result in entering raw chars instead of moving the cursor.
In cmd
, launching doskey
after the bun help
command, when the console has swithed to a raw mode, reverts the console to a normal mode, where arrows are usable. For a temporary workaround, it is possible to automate this by adding a bun
alias : doskey bun=bun $*$T@doskey
.
We've invested a ton of time into making Bun more reliable over the last year. I'm having a really hard time reproducing this. If you're still running into this issue, please let me know and I'll re-open this
Yes, the issue seems to be fixed now, cannot reproduce it either. Thanks. :)