Use "perl6" command with Git Bash on windows

I tried to install perl6 from the link you provided and I can confirm the same behavior on Cygwin on Windows 10.

If I type in the Cygwin terminal window:

$ perl6
-bash: perl6: command not found
$ echo  $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WINDOWS/System32/OpenSSH:/cygdrive/c/Users/Bruker/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/rakudo/bin:/cygdrive/c/rakudo/share/perl6/site/bin
$ cd /cygdrive/c/rakudo/bin
$ ls -l
-rwxrwx---+ 1 SYSTEM SYSTEM  930663 May 11  2017 libgcc_s_seh-1.dll
-rwxrwx---+ 1 SYSTEM SYSTEM  136146 Mar 30 20:55 libmoar.dll.a
-rwxrwx---+ 1 SYSTEM SYSTEM   56978 May 11  2017 libwinpthread-1.dll
-rwxrwx---+ 1 SYSTEM SYSTEM 7021172 Mar 30 20:55 moar.dll
-rwxrwx---+ 1 SYSTEM SYSTEM   64066 Mar 30 20:55 moar.exe
-rwxrwx---+ 1 SYSTEM SYSTEM     126 Mar 30 20:56 nqp.bat
-rwxrwx---+ 1 SYSTEM SYSTEM     126 Mar 30 20:56 nqp-m.bat
-rwxrwx---+ 1 SYSTEM SYSTEM     242 Mar 30 20:56 perl6.bat
-rwxrwx---+ 1 SYSTEM SYSTEM     248 Mar 30 20:56 perl6-debug-m.bat
-rwxrwx---+ 1 SYSTEM SYSTEM     242 Mar 30 20:56 perl6-m.bat
$ cat perl6.bat
@ "C:\rakudo\bin\moar" --execname="%~dpf0" --libpath="C:\rakudo\share\nqp\lib" --libpath="C:\rakudo\share\nqp\lib" --libpath="C:\rakudo\share/perl6/lib" --libpath="C:\rakudo\share/perl6/runtime" C:\rakudo\share\perl6\runtime\perl6.moarvm %*

Notice that the paths in the bat file are not cygwin paths. So that might explain why it does not work..

For example:

$ "C:\rakudo\bin\moar"
-bash: C:\rakudo\bin\moar: command not found
$  /cygdrive/c/rakudo/bin/moar
ERROR: Missing input file.

USAGE: moar [--crash] [--libpath=...] input.moarvm [program args]
       moar --dump input.moarvm
       moar --help
[...]

Update:

I also tried install Git Bash, and then from the MINGW64 terminal window:

$ echo $PATH
/c/Users/Bruker/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Bruker/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Users/Bruker/AppData/Local/Microsoft/WindowsApps:/usr/bin/vendor_perl:/usr/bin/core_perl
$ PATH=/c/rakudo/bin:$PATH
$ perl6
bash: perl6: command not found
$ moar
ERROR: Missing input file.
USAGE: moar [--crash] [--libpath=...] input.moarvm [program args]
       moar --dump input.moarvm
       moar --help
[...]

Note that moar is an .exe file while perl6 is a .bat file.

Also it seems perl6 is not "offical" for Cygwin yet according to this issue.


Bash doesn't run Windows batch files, so you'll have to work around that.

An easy solution might be to add something like this you your .bashrc:

alias perl6='cmd /c perl6.bat'

Alternatively, you can convert perl6.bat to a shell script and put it somewhere in your $PATH. I use the following:

#!/bin/sh

PATH=/cygdrive/c/rakudo/bin:/cygdrive/c/rakudo/share/perl6/site/bin:$PATH
unset HOME

moar --execname="$0" \
     --libpath='C:\rakudo\share\nqp\lib' \
     --libpath='C:\rakudo\share\perl6\lib' \
     --libpath='C:\rakudo\share\perl6\runtime' \
     'C:\rakudo\share\perl6\runtime\perl6.moarvm' \
     "$@"

This is using Cygwin; you may need to adapt it a bit for Git bash (I don't know, no experience with it).

Alternatively, if you're using Windows 10, I can recommend installing WSL, and using perl6 in a WSL bash prompt instead. This runs much smoother for me than the Windows version under Cygwin.