Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the perl6 equivalent of @INC, please?

Tags:

raku

I go

export PERL6LIB="/GitHub/perl6-Units/lib"

and then

echo $PERL6LIB
/GitHub/perl6-Units/lib

But when I run perl6 t/01-basic.t

use v6;

use Test;

plan 3;

lives-ok {
    use Units <m>;
    ok @Units::UNITS.elems > 0;
    ok (0m).defined;
} 

done-testing;

I still get an error

===SORRY!===
Could not find Units at line 8 in:
    /Users/--me--/.perl6
    /usr/local/Cellar/rakudo-star/2018.01/share/perl6/site
    /usr/local/Cellar/rakudo-star/2018.01/share/perl6/vendor
    /usr/local/Cellar/rakudo-star/2018.01/share/perl6
    CompUnit::Repository::AbsolutePath<140707489084448>
    CompUnit::Repository::NQP<140707463117264>
    CompUnit::Repository::Perl5<140707463117304>

In Perl 5 I would have used print "@INC"; to see what paths are searched for the lib before the error is thrown. Using say flat $*REPO.repo-chain.map(*.loaded); either is before it loads or after it throws the exception.

Any help would be much appreciated - or maybe a hint on what to put in ~/.perl6 as I can't get a symlink to work either.

like image 990
p6steve Avatar asked Sep 12 '18 18:09

p6steve


1 Answers

The error message itself is telling you what the library paths available are. You are failing to print them because you are expecting a run time action ( say ) to take place before a compile time error -- you could print out $*REPO at compile time, but again the exception is already showing you what you wanted.

$ PERL6LIB="/GitHub/perl6-Units/lib" perl6 -e 'BEGIN say $*REPO.repo-chain; use Foo;'
(file#/GitHub/perl6-Units/lib inst#/Users/ugexe/.perl6 inst#/Users/ugexe/.rakudobrew/moar-2018.08/install/share/perl6/site inst#/Users/ugexe/.rakudobrew/moar-2018.08/install/share/perl6/vendor inst#/Users/ugexe/.rakudobrew/moar-2018.08/install/share/perl6 ap# nqp# perl5#)
===SORRY!===
Could not find Foo at line 1 in:
    /GitHub/perl6-Units/lib
    /Users/ugexe/.perl6
    /Users/ugexe/.rakudobrew/moar-2018.08/install/share/perl6/site
    /Users/ugexe/.rakudobrew/moar-2018.08/install/share/perl6/vendor
    /Users/ugexe/.rakudobrew/moar-2018.08/install/share/perl6
    CompUnit::Repository::AbsolutePath<140337382425072>
    CompUnit::Repository::NQP<140337350057496>
    CompUnit::Repository::Perl5<140337350057536>

You can see /GitHub/perl6-Units/lib is showing up in the available paths, which is unlike your example. I'd question if your shell/env is actually setup correctly.

like image 126
ugexe Avatar answered Oct 28 '22 06:10

ugexe