Skip to content
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

Support for msys2 bash #99

Open
henrik-jensen opened this issue Dec 31, 2018 · 16 comments
Open

Support for msys2 bash #99

henrik-jensen opened this issue Dec 31, 2018 · 16 comments

Comments

@henrik-jensen
Copy link

Executables

Version of bash-debug: 0.3.3

c:\> where bash
C:\Windows\System32\bash.exe

# executed from msys2 bash:
c:\> c:\msys64\msys2_shell.cmd -mingw64 -defterm -here -no-start
$ where bash
C:\msys64\usr\bin\bash.exe
C:\Windows\System32\bash.exe

c:\> code --version
1.30.1
dea8705087adb1b5e5ae1d9123278e178656186a
x64

# executed from msys2 bash:
c:\> c:\msys64\msys2_shell.cmd -mingw64 -defterm -here -no-start
$ bash -c 'uname -a; for P in bash bashdb cat mkfifo pkill; do echo ---; which -a $P; command $P --
version; done'
MINGW64_NT-10.0 superputte 2.11.1(0.329/5/3) 2018-09-10 14:19 x86_64 Msys
---
/usr/bin/bash
/bin/bash
/c/Windows/System32/bash
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
---
which: no bashdb in (/home/henrik/usr/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
bash: bashdb: command not found
---
/usr/bin/cat
/bin/cat
cat (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund and Richard M. Stallman.
---
/usr/bin/mkfifo
/bin/mkfifo
mkfifo (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
---
/usr/bin/pkill
/bin/pkill
pkill from procps-ng 3.3.12

Debug output

N/A

Details

Is it possible to use msys2 bash as an alternative to wsl.exe? wsl (ubuntu 18.04) works fine but I would like to debug some scripts under msys2.

@rogalmic
Copy link
Owner

rogalmic commented Jan 1, 2019

For now this is not supported, but i will add it to potential TODO list.

The problem here might be another filesystem path mapping ( WSL c:\=> /mnt/c/, MSYS2 c:\ => /c/).

I assume msys2 console cannot handle native windows path, right?

@henrik-jensen
Copy link
Author

henrik-jensen commented Jan 1, 2019

I assume msys2 console cannot handle native windows path, right?

Well, only when enclosed in double quotes '"'.

# The three paths are all equivalent
henrik@superputte MINGW64 ~
$ ls  "c:\this\path does\exist" \
>      c:/this/path\ does/exist \
>      /c/this/path\ does/exist
'/c/this/path does/exist':
'some file.txt'

'c:/this/path does/exist':
'some file.txt'

'c:\this\path does\exist':
'some file.txt'

I don't know how fragile this (heuristic?) system is but I always use the unix style /c/this/path\ does/exist to be sure.

@starship863
Copy link

Looking forward to this feature! Also the bash in git for windows please, which is identical to the msys2 bash.

@rogalmic
Copy link
Owner

I took a look at this, it will not be that easy, for example:

  1. pkill is missing from git bash.exe
  2. there seems to be some issue with outputting bashdb to fifo file

I will check this fully once I have more time.

@rogalmic
Copy link
Owner

rogalmic commented Jan 15, 2019

I have narrowed it down to this problem:

  • open 2 console instances of Git Bash
  • start this in first one:
mkfifo /tmp/testpipe ; exec 3<>/tmp/testpipe ; cat <&3
  • start this in second:
echo "test" >/tmp/testpipe ; echo "test2" >/tmp/testpipe ; 

This works ok when i run two WSL consoles (or in Linux), and seems to be a reason why i cannot get this working.

Any help with solving this would be appreciated, since this is the way how bashdb sends/receives debuuger input/output (stdin and stdout are used for debugged script)...

@starship863
Copy link

starship863 commented Jan 15, 2019

I have narrowed it down to this problem:

  • open 2 console instances of Git Bash consoles
  • start this in first one:
    ...

Thank you very much for your efforts!

@henrik-jensen
Copy link
Author

@rogalmic - Also big thanks from me.
Git bash is derived from msys(2?) which is derived from cygwin. iirc Cygwin should be much closer to POSIX compliance so it may work under cygwin?
Could one imagine some thin cygwin layer or shim to emulate the linux pipes? Though of course you wouldn't really be debugging msys/git bash but cygwin in some cases. -> Works in the debugger but not in production, hmm?

@rogalmic
Copy link
Owner

I tested cygwin, git-bash, mingw - they all seem to have problems with fifo support.

Like you commented, this is probably because how those windows solutions are designed:

  • cygwin
rogalmic@WW302902 /usr/bin
$ /usr/bin/mount
C:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin64 on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
  • mingw
rogalmic@WW302902 MINGW64 /bin
$ mount
C:/Program Files/Git on / type ntfs (binary,noacl,auto)
C:/Program Files/Git/usr/bin on /bin type ntfs (binary,noacl,auto)
C:/Users/rogalmic/AppData/Local/Temp on /tmp type ntfs (binary,noacl,posix=0,usertemp)
C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)

Underlying bashdb outputs debug io to some kid of file - hence the fifo usage.

Maybe the best way would be to make fifo work in cygwin/mingw would be to have /tmp mounted as tmpfs? I guess this is not supported, possibly by design...

@endmarsfr
Copy link

Hi,

Pycharm has a plugin Bashsupport-pro which works fine with wsl, msys2, linux, macosx.

Pycharm use bashdb too just like vscode-bash-debug
So it is feasable to work with msys2.

keep the faith ;)

Regards

@endmarsfr
Copy link

endmarsfr commented Apr 6, 2023

echo "test" >/tmp/testpipe ; echo "test2" >/tmp/testpipe ; 

This working now with bash
GNU bash, version 5.2.15(1)-release (x86_64-pc-msys)
and
MSYS_NT-10.0-19045 version 3.4.6.x86_64 (runneradmin@fv-az411-253) (gcc version 11.3.0 (GCC) ) 2023-04-01 11:43 UTC

image

image

@endmarsfr
Copy link

I have narrowed it down to this problem:

  • open 2 console instances of Git Bash
  • start this in first one:
mkfifo /tmp/testpipe ; exec 3<>/tmp/testpipe ; cat <&3
  • start this in second:
echo "test" >/tmp/testpipe ; echo "test2" >/tmp/testpipe ; 

This works ok when i run two WSL consoles (or in Linux), and seems to be a reason why i cannot get this working.

Any help with solving this would be appreciated, since this is the way how bashdb sends/receives debuuger input/output (stdin and stdout are used for debugged script)...

Now it works :) !

@henrik-jensen
Copy link
Author

@endmarsfr Thanks. 👍
I must try it out. But my vscode installation, (actually my whole system) is in a bit of a mess right now, so my feedback on this have to wait a few days.

@endmarsfr
Copy link

@endmarsfr Thanks. 👍 I must try it out. But my vscode installation, (actually my whole system) is in a bit of a mess right now, so my feedback on this have to wait a few days.

@henrik-jensen, I hope you could give us your feedback soon
Best regards

@mariuszmaximus
Copy link

I'm also waiting for a msys2 fix 👍

@henrik-jensen
Copy link
Author

henrik-jensen commented Nov 12, 2023

@endmarsfr Thanks. 👍 I must try it out. But my vscode installation, (actually my whole system) is in a bit of a mess right now, so my feedback on this have to wait a few days.

@henrik-jensen, I hope you could give us your feedback soon Best regards

@endmarsfr I'm so sorry for the promises I gave. A few days have turned into several month (over 8 month actually) and I haven't really tried to fix my system. Too afraid it might break something. I really wish I weren't so laissez-faire with my system setup in the past. I will slowly try to get back into bash/vscode extension mode of thinking and, at some point in time, hopefully sooner than later, maybe give you some kind of valuable feedback.

@endmarsfr
Copy link

Hi @henrik-jensen
Thank you for this information, I hope your business will get better soon and always hope for good news from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants