Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl6 script on MSYS2 causes 'failed to stat file' error

When I try to run a simple perl6 script on MSYS2-64 (bash.exe) on Windows 7 it says:

Could not open my-perl6-script.pl. Failed to stat file: no such file or directory

The same script runs perfectly fine on CMD.exe so I guess it's some incompatibility between perl6 and MSYS2.

$ perl6 -v returns:

This is Rakudo Star version 2018.04.1 built on MoarVM version 2018.04.1 implementing Perl 6.c.

The bin folder of perl6 is:

-rwxr-xr-x 1 win7 None  537938 May 11  2015 libgcc_s_sjlj-1.dll
-rw-r--r-- 1 win7 None  130262 May  7  2018 libmoar.dll.a
-rwxr-xr-x 1 win7 None   57681 May 11  2015 libwinpthread-1.dll
-rwxr-xr-x 1 win7 None 6633702 May  7  2018 moar.dll
-rwxr-xr-x 1 win7 None   57225 May  7  2018 moar.exe
-rw-r--r-- 1 win7 None     104 May  7  2018 nqp.bat
-rw-r--r-- 1 win7 None     104 May  7  2018 nqp-m.bat
lrwxrwxrwx 1 win7 None      23 Jun 19  2018 perl6 -> /c/rakudo/bin/perl6.exe
-rw-r--r-- 1 win7 None     242 May  7  2018 perl6.bat
lrwxrwxrwx 1 win7 None      23 Jun 19  2018 perl6.exe -> /c/rakudo/bin/perl6.bat
-rw-r--r-- 1 win7 None     248 May  7  2018 perl6-debug-m.bat
-rw-r--r-- 1 win7 None     242 May  7  2018 perl6-m.bat

It doesn't matter if I run the script using perl6, perl6.exe or perl6.bat; they all give the same error. I'd like to run perl6 scripts on MSYS2-64. What should I do? Thanks

like image 328
Terry Avatar asked Jul 15 '19 12:07

Terry


1 Answers

I installed Rakudo for Windows and made a custom perl6 shell script:

#!/bin/sh
/c/rakudo/bin/moar --execname="$0" --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' "$@"

I copied perl6.bat to perl6, changed the initial path to moar to an MSYS-style path, and changed from cmd to sh quoting and arugment conventions.

Example run, from cmd:

C:\Users\cxw>perl6 -v
This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
implementing Perl 6.d.

From the shell opened by msys2_shell.cmd:

$ uname -a
MSYS_NT-6.1-7601 Desktop 3.0.7-338.x86_64 2019-07-03 08:42 UTC x86_64 Msys
$ export PATH="$PATH":~/bin
$ cat foo.p6
use v6;
(2+2).say;
$ perl6 foo.p6
4

For what it's worth, my Rakudo bin dir:

$ ls -l /c/rakudo/bin
total 8033
-rwxr-xr-x 1 cxw None  930663 May 11  2017 libgcc_s_seh-1.dll
-rw-r--r-- 1 cxw None  136146 Mar 30 21:55 libmoar.dll.a
-rwxr-xr-x 1 cxw None   56978 May 11  2017 libwinpthread-1.dll
-rwxr-xr-x 1 cxw None 7021172 Mar 30 21:55 moar.dll
-rwxr-xr-x 1 cxw None   64066 Mar 30 21:55 moar.exe
-rw-r--r-- 1 cxw None     126 Mar 30 21:56 nqp.bat
-rw-r--r-- 1 cxw None     126 Mar 30 21:56 nqp-m.bat
-rw-r--r-- 1 cxw None     242 Mar 30 21:56 perl6.bat
-rw-r--r-- 1 cxw None     248 Mar 30 21:56 perl6-debug-m.bat
-rw-r--r-- 1 cxw None     242 Mar 30 21:56 perl6-m.bat
like image 93
cxw Avatar answered Oct 05 '22 23:10

cxw