ugexe / zef

Raku Module Management
Artistic License 2.0
210 stars 45 forks source link

zef tests with Perl 5 prove #326

Closed waterkip closed 4 years ago

waterkip commented 4 years ago

I wanted to install App::Prove6 and when I do that I get the following error:

$ zef install App::Prove6
===> Searching for: App::Prove6
===> Searching for missing dependencies: TAP:ver<0.1.0+>, Getopt::Long
===> Testing: TAP:ver<0.1.0>
===> Testing [OK] for TAP:ver<0.1.0>
===> Testing: Getopt::Long:ver<0.1.3>
[Getopt::Long] Perl v6.0.0 required--this is only v5.30.0, stopped at lib/Getopt/Long.pm line 1.
[Getopt::Long] BEGIN failed--compilation aborted at lib/Getopt/Long.pm line 1.
[Getopt::Long] Compilation failed in require at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] Compilation failed in require at /usr/bin/prove line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/bin/prove line 9.
===> Testing [FAIL]: Getopt::Long:ver<0.1.3>
Aborting due to test failure: Getopt::Long:ver<0.1.3> (use --force-test to override)

The behaviour can be triggered by just installing (or trying to install) Getopt::Long:

$ zef install --debug Getopt::Long
===> Searching for: Getopt::Long
===> Found: Getopt::Long:ver<0.1.3> [via Zef::Repository::LocalCache]
===> Filtering: Getopt::Long:ver<0.1.3>
===> Filtering [OK] for Getopt::Long:ver<0.1.3>
===> # SKIP: No need to build Getopt::Long:ver<0.1.3>
===> Testing: Getopt::Long:ver<0.1.3>
[Getopt::Long] Testing with plugin: Zef::Service::Shell::prove+{<anon|1>}
[Getopt::Long] Perl v6.0.0 required--this is only v5.30.0, stopped at lib/Getopt/Long.pm line 1.
[Getopt::Long] BEGIN failed--compilation aborted at lib/Getopt/Long.pm line 1.
[Getopt::Long] Compilation failed in require at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] Compilation failed in require at /usr/bin/prove line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/bin/prove line 9.
===> Testing [FAIL]: Getopt::Long:ver<0.1.3>
Aborting due to test failure: Getopt::Long:ver<0.1.3> (use --force-test to override)

My environment looks like this:

$ perl6 -v
This is Rakudo version 2019.07.1 built on MoarVM version 2019.07.1
implementing Perl 6.d.

$ zef --version
v0.8.0

$ zef list --installed
===> Found via /usr/share/perl6/vendor
Readline:ver<0.1.5>:auth<github:drforr>
TAP::Harness:ver<0.0.4>:auth<Leon Timmermans>
zef:ver<0.8.0>:auth<github:ugexe>:api<0>
===> Found via /usr/share/perl6/site
Concurrent::Stack:ver<1.2>
Config::Parser::toml:ver<1.0.1>:auth<github:scriptkitties>
Config::TOML:ver<0.1.1>:auth<atweiden>
Config:ver<2.1.0>:auth<github:scriptkitties>:api<2>
Crane:ver<0.1.0>:auth<atweiden>
DB::SQLite:ver<0.3>
DB:ver<0.4>
DBIish:ver<0.5.19>
Data::Dump:ver<v.0.0.11>:auth<github:tony-o>
Hash::Merge:ver<1.0.0>:auth<github:scriptkitties>:api<1>
IO::Path::XDG:ver<0.1.0>:api<0>
JSON::Fast:ver<0.10>
NativeHelpers::Blob:ver<0.1.12>:auth<github:salortiz>
String::Fold:ver<0.2.0>:api<0>
===> Found via /usr/share/perl6/core
CORE:ver<6.d>:auth<perl>
===> Found via /home/wesleys/.perl6
App::GTD:ver<0.0.0>:api<0>
ugexe commented 4 years ago

It doesn't seem possible for zef to launch prove with perl since it essentially just does prove -v -e /path/to/perl6 t/: https://github.com/ugexe/zef/blob/0484e30ba82f7860b785e2a1d7759379b2c78488/lib/Zef/Service/Shell/prove.pm6#L38

You might try cloning zef, adding some debug output around that spot -- maybe a say $proc.perl to see the full command being used (sans setting up PERL6LIB) -- to see if you can golf the issue down. Run zef via perl6 -I. bin/zef install Getopt::Long --debug (don't install zef so you can iterate on your changes without reinstalling each time)

waterkip commented 4 years ago

This is funny:

$ perl6 -I. bin/zef install --debug --test Getopt::Long
===> Searching for: Getopt::Long
===> Found: Getopt::Long:ver<0.1.3> [via Zef::Repository::LocalCache]
===> Filtering: Getopt::Long:ver<0.1.3>
===> Filtering [OK] for Getopt::Long:ver<0.1.3>
===> # SKIP: No need to build Getopt::Long:ver<0.1.3>
===> Testing: Getopt::Long:ver<0.1.3>
[Getopt::Long] Testing with plugin: Zef::Service::Shell::prove+{<anon|1>}
/usr/bin/perl6 # say $*EXECUTABLE.absolute
(prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 t) # say $proc.cmd
[Getopt::Long] Perl v6.0.0 required--this is only v5.30.0, stopped at lib/Getopt/Long.pm line 1.
[Getopt::Long] BEGIN failed--compilation aborted at lib/Getopt/Long.pm line 1.
[Getopt::Long] Compilation failed in require at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] Compilation failed in require at /usr/bin/prove line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/bin/prove line 9.
===> Testing [FAIL]: Getopt::Long:ver<0.1.3>
Aborting due to test failure: Getopt::Long:ver<0.1.3> (use --force-test to override)

19:03 pts/2 1 wesleys@neptune:/home/wesleys/code/zef
$ prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 t
t/00-load.t ....................... ok
t/build.t ......................... ok
t/distribution-depends-parsing.t .. ok
t/extract.t ....................... ok
t/fetch.t ......................... ok
t/identity.t ...................... ok
t/install.t ....................... ok
t/repository.t .................... ok
t/test.t .......................... ok
t/utils-filesystem.t .............. ok
All tests successful.
Files=10, Tests=22, 10 wallclock secs ( 0.04 usr  0.00 sys +  7.75 cusr  0.37 csys =  8.16 CPU)
Result: PASS
waterkip commented 4 years ago

OK, I found the bug, but am not sure why.

I have a PERL5LIB which includes "./lib", if you run zef with this PERL5LIB, it b0rks. If I unset it, it works fine. If I have the PERL5LIB in place and I just run the command zef runs it also works fine. So.. zef is doing what exactly with the environment variable?

$ export PERL5LIB=./lib:/home/wesleys/.local/lib/perl5
19:15 pts/2 0 wesleys@neptune:/home/wesleys/code/zef
$ perl6 -I. bin/zef install --debug --test --force-install Getopt::Long
The following candidates are already installed: Getopt::Long
===> Searching for: Getopt::Long
===> Found: Getopt::Long:ver<0.1.3> [via Zef::Repository::LocalCache]
===> Filtering: Getopt::Long:ver<0.1.3>
===> Filtering [OK] for Getopt::Long:ver<0.1.3>
===> # SKIP: No need to build Getopt::Long:ver<0.1.3>
===> Testing: Getopt::Long:ver<0.1.3>
[Getopt::Long] Testing with plugin: Zef::Service::Shell::prove+{<anon|1>}
/usr/bin/perl6
(/usr/bin/prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 t)
[Getopt::Long] Perl v6.0.0 required--this is only v5.30.0, stopped at lib/Getopt/Long.pm line 1.
[Getopt::Long] BEGIN failed--compilation aborted at lib/Getopt/Long.pm line 1.
[Getopt::Long] Compilation failed in require at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/share/perl/5.30/App/Prove.pm line 9.
[Getopt::Long] Compilation failed in require at /usr/bin/prove line 9.
[Getopt::Long] BEGIN failed--compilation aborted at /usr/bin/prove line 9.
===> Testing [FAIL]: Getopt::Long:ver<0.1.3>
Aborting due to test failure: Getopt::Long:ver<0.1.3> (use --force-test to override)
19:15 pts/2 1 wesleys@neptune:/home/wesleys/code/zef
$ unset PERL5LIB
19:17 pts/2 0 wesleys@neptune:/home/wesleys/code/zef
$ perl6 -I. bin/zef install --debug --test --force-install Getopt::Long
The following candidates are already installed: Getopt::Long
===> Searching for: Getopt::Long
===> Found: Getopt::Long:ver<0.1.3> [via Zef::Repository::LocalCache]
===> Filtering: Getopt::Long:ver<0.1.3>
===> Filtering [OK] for Getopt::Long:ver<0.1.3>
===> # SKIP: No need to build Getopt::Long:ver<0.1.3>
===> Testing: Getopt::Long:ver<0.1.3>
[Getopt::Long] Testing with plugin: Zef::Service::Shell::prove+{<anon|1>}
/usr/bin/perl6
(/usr/bin/prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 t)
[Getopt::Long] t/basic.t .. ok
[Getopt::Long] All tests successful.
[Getopt::Long] Files=1, Tests=26,  0 wallclock secs ( 0.01 usr  0.00 sys +  0.60 cusr  0.04 csys =  0.65 CPU)
[Getopt::Long] Result: PASS
===> Testing [OK] for Getopt::Long:ver<0.1.3>
===> Installing: Getopt::Long:ver<0.1.3>
===> Install [OK] for Getopt::Long:ver<0.1.3>
ugexe commented 4 years ago

That is strange indeed -- I would have expected prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 t to fail as well... but somehow setting PERL5LIB only breaks prove when zef invokes it (which is using the command listed earlier...)?

@Leont got any ideas?

ugexe commented 4 years ago

Also note that when you used prove directly you ran zef's tests, not Getopt::Long. I think you would need to do:

prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 /home/wesleys/.zef/store/Getopt-Long-0.1.3.tar.gz/Getopt-Long-0.1.3/t
waterkip commented 4 years ago

Smart :) But it works

$ env | grep PERL
PERL_LOCAL_LIB_ROOT=/home/wesleys/.local
PERL_MB_OPT=--install_base '/home/wesleys/.local'
PERL_MM_OPT=INSTALL_BASE=/home/wesleys/.local
PERL5LIB=./lib:.t/lib:./t/inc:/home/wesleys/.local/lib/perl5
20:28 pts/2 0 wesleys@neptune:/home/wesleys/code/zef
$ prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 /home/wesleys/.zef/store/Getopt-Long-0.1.3.tar.gz/Getopt-Long-0.1.3/t
/home/wesleys/.zef/store/Getopt-Long-0.1.3.tar.gz/Getopt-Long-0.1.3/t/basic.t .. ok
All tests successful.
Files=1, Tests=26,  1 wallclock secs ( 0.02 usr  0.00 sys +  1.33 cusr  0.07 csys =  1.42 CPU)
Result: PASS
Leont commented 4 years ago

I have a PERL5LIB which includes "./lib"

Yeah, that's asking for trouble

Smart :) But it works

But it will fail if you run

prove --ext .rakutest --ext .t --ext .t6 -r -e /usr/bin/perl6 t

from the Getopt::Long directory.

ugexe commented 4 years ago

@waterkip to clarify what is happening is that zef changes to the directory of Getopt::Long when running that prove command. Presumably prove uses Perl (5) Getopt::Long, so having ./lib in PERL5LIB makes prove try and load the Raku/Perl6 Getopt::Long (since in this case they share the same file extension -- .pm).

You can avoid this by using --/prove option with zef to disable the prove plugin. In the far off future raku modules will stop using/allowing the .pm file extension, and this issue will resolve itself.