-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactive MSVC Nushell doesn't work under Cygwin Mintty with disable_pcon (e.g. Git Bash) #10808
Comments
Hm, I've not yet been able to reproduce on my local (win11) desktop. But I can when repeating your steps in a sandbox. I'm not sure what the difference is. Possibly some git setting I've used as I installed it from the GUI installer awhile back. Btw, this is probably unrelated but the git-bash window really does not like the sandbox. It seems to mess up window switching and input focus somehow. |
I don't have time to investigate right now but my suspicion would be it's the difference between msys2 passing asynchronous pipes that emulate a terminal (inherited from cygwin) vs. using the built-in pseudo console that appears like a regular console. I believe git allows you to change this while installing but I'm uncertain how to do it after the fact. If anyone wants to investigate this before I get round to it then |
Ok, because this is bugging me I did find the cause. Here's how to fix it on the user's machine: Open So my suggestion would be for nushell to:
|
Potential env to sniff to determine terminal context: > # in wt
> let env_wt = (nu -c "$env | to json" | str replace -a "\u{1b}" '(char esc)' | from json)
> # Git Bash: nu -c "\$env | to json" | clip
> let env_git = (pwsh -c `Get-Clipboard` | str replace -a "\u{1b}" '(char esc)' | from json)
> $env_wt | transpose key val | filter { ($in.key | str upcase) not-in ($env_git | transpose key val | get key | str upcase) } value
> $env_git | transpose key val | filter { ($in.key | str upcase) not-in ($env_wt | transpose key val | get key | str upcase) } value
So it looks like a reasonably precise test for "mintty without pseudo console" could be $env.TERM_PROGRAM == mintty and ($env.MSYS? =~ \bdisable_pcon\b or $env.CYGWIN? =~ \bdisable_pcon\b) I don't really know anything about pty / conPTY support. I think if !stdout.is_terminal() {
eprintln!("refusing to run interactive shell outside terminal");
exit(1);
}
#[cfg(windows)]
if !stdout.is_console() {
eprintln!("It looks like you're running in a mingw environment without conPTY support.");
if let Ok(mingw_prefix) = env::var("MINGW_PREFIX") && mingw_prefix.contains("Git") {
eprintln!("Git Bash sets MSYS=disable_pcon by default, disabling conPTY; consider not doing that.");
}
exit(1);
} ...assuming that when conPTY support is used, |
Yes, this was considered a requirement for bringing it into Rust's std, otherwise popular crates wouldn't use it. Most people just want to roughly know, in the absence of arguments, a) should I use colour and b) is this interactive. Tbh, I'd love to eventually remove the test for msys/cygwin from std once conPTY becomes widespread enough because it's not great and it's very specific to two terminal emulators (albeit popular ones). But we're not there yet.
We do have this internally but exposing platform specific stuff always comes with the question "why isn't this just a crate". And in this particular case it does also have the issue of what happens if we do remove the msys check from For what it's worth, let mut mode = 0;
let is_console = GetConsoleMode(handle, &mut mode) != 0; Of course a third option would be for nushell to support msys/cygwin's pipes. But that doesn't solve the immediate problem and it probably requires dependencies to be updated to support it, which is a whole ecosystem problem. It's also maybe not possible if msys is missing support for some console thing nushell requires. Idk the details here. |
I was looking into the crossterm source how it tries to do its Windows terminal capability sniffing (for #10998 / #11045 I stumbeled accross the same weirdness): As a proxy they seem to look for the presence of A related issue on their side specifically for the Windows Git bash: |
Describe the bug
If
nu
is run from the Git Bash terminal (a cygwin mintty terminal, distributed as part of Git for Windows), the interactive prompt does not function and the session is inescapable; typing ENTER moves the cursor to the next line but does not cause a response from the nu prompt, and even CTRL+C has no effect. The arrow keys can be used to move the cursor around in the screen buffer arbitrarily and edit anywhere.How to reproduce
winget install Nushell.Nushell; winget install Git.Git
)nu
.nu
(or do anything other than edit the text buffer) is to close Git Bash.Expected behavior
I expected nu to work, or at a minimum to detect the incompatible terminal/environment and error instead of softlocking the terminal.
Screenshots
Configuration
Additional context
cmd.exe
does not seem to have this issue, butpwsh
has an equivalent one. An initial guess was mintty sending\n
instead of\r\n
, but the behavior is far weirder than could reasonably be just that.The text was updated successfully, but these errors were encountered: