Search code examples
raku

What is the raku equivalent of @INC, please?


I go

export RAKULIB="/GitHub/raku-Units/lib"

and then

echo $RAKULIB
/GitHub/raku-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 ~/.raku as I can't get a symlink to work either.


Solution

  • 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.

    $ RAKULIB="/GitHub/raku-Units/lib" raku -e 'BEGIN say $*REPO.repo-chain; use Foo;'
    (file#/GitHub/raku-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/raku-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/raku-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.