rogalmic / vscode-bash-debug

Bash shell debugger extension for VSCode (based on bashdb)
MIT License
217 stars 26 forks source link

Support for msys2 bash #99

Open henrik-jensen opened 5 years ago

henrik-jensen commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

rogalmic commented 5 years ago

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 commented 5 years ago

I have narrowed it down to this problem:

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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:

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 commented 1 year ago

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 commented 1 year ago
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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

@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 commented 11 months ago

I'm also waiting for a msys2 fix 👍

henrik-jensen commented 10 months ago

@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 commented 10 months ago

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