Perl6 script on MSYS2 causes 'failed to stat file' error
Asked Answered
O

1

7

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

Oxa answered 15/7, 2019 at 12:1 Comment(5)
Maybe Use “perl6” command with Git Bash on windows is helpful. (Please let us know either way.)Unroot
Having looked at the last comment at that thread, I've noticed bash.exe not being able to correctly see the arguments after the perl6.bat that is the Perl script to be executed. Then I tried giving the full path of the script and then it worked. So the problem is now (supposedly): perl6.bat can't get the path correctly.Oxa
Which thread? I'm not understanding how Håkon's comment relates. Do you mean jnthn's comment in Rakudo issue #2807?Unroot
I mean the comment whics proposes using cmd "/c perl6 --version" with the bash.Oxa
OK. I don't use Windows and I'm out of ideas. Maybe there are .bat or .sh files with / instead of \ in them or vice-versa? Maybe stackoverflow.com/search?q=%5Bperl6%5D+bash helps? (If so, please let us know.) If no one else replies soon here on SO then I recommend you file an issue at github.com/rakudo/rakudo/issues/new with MSYS2 and Windows 7 in the title, linking to this SO, and giving whatever details you can about your setup, what you've tried, and what progress you've made. That will get a fresh set of eyes on the problem.Unroot
M
5

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
Madelle answered 16/7, 2019 at 12:20 Comment(1)
That did the trick. It works now. I've just copied that perl6 scriptlet into my bin folder as it is (without modifiying anything) and it did work. Thanks. Now I've got some 2 more issues with Perl 6, such as handling the Unicode characters correctly while reading from files (which Perl 5 does correctly) and using the module IO::Glob , it just didn't work in Perl 6 but I guess it might have something to do with the MSYS2 again. I will post these questions soon. Thank you.Oxa

© 2022 - 2024 — McMap. All rights reserved.