git-bonsai icon indicating copy to clipboard operation
git-bonsai copied to clipboard

Crashes under Windows 10 Git Bash console

Open eddyp opened this issue 5 years ago • 5 comments

On a fresh clone of git-bonsai repo itself...

user@W10 MINGW64 /c/Temp/test/git-bonsai (bar)
$ git show
commit 5433583c9284e396fe0578db17b08731521b75ed (HEAD -> bar, tag: 0.1.0, origin/master, origin/HEAD, master, foo)
Merge: 53c9811 bd62845
Author: Aurelien Gateau <[email protected]>
Date:   Sun Mar 22 15:22:58 2020 +0100

    Merge branch 'dev'


user@W10 MINGW64 /c/Temp/test/git-bonsai (bar)
$ git remote -v
origin  https://github.com/agateau/git-bonsai.git (fetch)
origin  https://github.com/agateau/git-bonsai.git (push)

On windows 10, under Git Bash console git-bonsai crashes:

user@W10 MINGW64 /c/Temp/test/git-bonsai (master)
$ git co -b foo
Switched to a new branch 'foo'

user@W10 MINGW64 /c/Temp/test/git-bonsai (foo)
$ git co -b bar
Switched to a new branch 'bar'

user@W10 MINGW64 /c/Temp/test/git-bonsai (bar)
$ RUST_BACKTRACE=full git bonsai
Info: Fetching changes
Info: Updating master
Already up to date.

Select branches to delete:
> [x] foo, contained in:
      - master

  [x] bar, contained in:
      - master

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 1, kind: Other, message: "Incorrect function." }', C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\git-bonsai-0.1.0\src\tui.rs:38:5
stack backtrace:
   0:     0x7ff7b7d7faaf - <unknown>
   1:     0x7ff7b7d9756b - <unknown>
   2:     0x7ff7b7d7bcfc - <unknown>
   3:     0x7ff7b7d82f8c - <unknown>
   4:     0x7ff7b7d82bdf - <unknown>
   5:     0x7ff7b7d836e7 - <unknown>
   6:     0x7ff7b7d8326f - <unknown>
   7:     0x7ff7b7d96870 - <unknown>
   8:     0x7ff7b7d966a3 - <unknown>
   9:     0x7ff7b7d04226 - <unknown>
  10:     0x7ff7b7d09918 - <unknown>
  11:     0x7ff7b7d0b399 - <unknown>
  12:     0x7ff7b7d04506 - <unknown>
  13:     0x7ff7b7d83107 - <unknown>
  14:     0x7ff7b7d8caa2 - <unknown>
  15:     0x7ff7b7d83928 - <unknown>
  16:     0x7ff7b7d0b3d7 - <unknown>
  17:     0x7ff7b7d9cfa0 - <unknown>
  18:     0x7ffbcf407bd4 - BaseThreadInitThunk
  19:     0x7ffbd12cce51 - RtlUserThreadStart

user@W10 MINGW64 /c/Temp/test/git-bonsai (bar)
$ uname -a
MINGW64_NT-10.0-18362 NXL71399 3.0.7-338.x86_64 2019-11-21 23:07 UTC x86_64 Msys

This does not happen if ran from cmd:

Microsoft Windows [Version 10.0.18362.778]
(c) 2019 Microsoft Corporation. All rights reserved.

c:\temp\test\git-bonsai>git bonsai
Info: Fetching changes
Info: Updating master
Already up to date.

Select branches to delete: foo, contained in:
      - master

Info: Deleting foo

eddyp avatar May 25 '20 14:05 eddyp

Hi, thanks for the report. It looks like a bug in dialoguer. I tried to update from 0.5.0 to 0.6.2 but it is even more broken :/ Going to check if it can be fixed or if I have to switch to another input handling crate.

agateau avatar May 27 '20 06:05 agateau

After more rabbit-hole digging, I found out this is an issue with Mintty, the terminal emulator used by Git Bash. One workaround is to wrap the call to git-bonsai with winpty, as explained here: https://github.com/mintty/mintty/wiki/Tips#inputoutput-interaction-with-alien-programs.

I don't know if this is solvable, but if it is I suspect the fix would have to be implemented in the console crate, which dialoguer uses to interact with the terminal. I'll file a bug there later today.

agateau avatar May 27 '20 08:05 agateau

Turns out it has already been reported as https://github.com/mitsuhiko/console/issues/35. Closing this for now as I can't do anything here. I am subscribed to the console bug, so will update the dependencies when/if it gets fixed.

agateau avatar May 27 '20 20:05 agateau

I understand the cause is external, but I would have expected the bug to be kept open until is solved here.

Still, it's your project, I won't be a choosing beggar. :grin:

eddyp avatar May 28 '20 10:05 eddyp

Mmm, you are right, let's keep it open, it will be easier to find if others have the same issue.

And since there is always the option of switching to another crate to get input, there might be something which can be done on git-bonsai side.

agateau avatar May 29 '20 07:05 agateau