Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use "perl6" command with Git Bash on windows

Using Windows, I installed Rakudo Star and Git and ensured that C:\rakudo\bin and C:\rakudo\share\perl6\site\bin are in my Path environment variable.

Now, typing perl6 inside Git Bash afterwards gives the command not found error, while the command does work inside powershell and cmd. Typing echo $PATH inside Git Bash confirms again that the folders above are in my path variable here as well.

How can I get the perl6 command working inside Git Bash?

Note: Using moar (moar.exe) which resides in the same folder as perl6 works as well in Git Bash. Also hitting Tab show the autocomplete suggestion for moar, it does not do that for perl6.

like image 789
Jessica Nowak Avatar asked May 28 '19 16:05

Jessica Nowak


People also ask

How do I use git Bash on Windows?

Step 1: Go to Github repository and in code section copy the URL. Step 2: In the Command prompt, add the URL for your repository where your local repository will be pushed. Step 3: Push the changes in your local repository to GitHub. Here the files have been pushed to the master branch of your repository.

Can I use git Bash instead of CMD in Windows?

You don't need to use Git Bash. It is just conventional, because Git was developed and designed on Linux and most Git users use Linux and using Git Bash on Windows makes it a uniform experience. You can certainly use Git on cmd; just make sure you add C:\Program Files\git\cmd to your PATH .

How do I run an EXE file in Bash?

To run a Windows program, enter the path to the program's .exe file in the Bash shell. Remember that your Windows C: drive is available at /mnt/c in Bash. The Bash environment is also case-sensitive, so you have to specify the correct capitalization.


2 Answers

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.

like image 176
mscha Avatar answered Oct 25 '22 16:10

mscha


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.

like image 25
Håkon Hægland Avatar answered Oct 25 '22 16:10

Håkon Hægland