请问@INC的perl6等效项是什么?

时间:2018-09-12 18:13:24

标签: perl6 raku

我去

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

然后

echo $PERL6LIB
/GitHub/perl6-Units/lib

但是当我运行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;

我仍然遇到错误

===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>

在Perl 5中,我将使用print "@INC";来查看在引发错误之前搜索lib的路径。在加载前或引发异常后使用say flat $*REPO.repo-chain.map(*.loaded);

任何帮助将不胜感激-或暗示~/.perl6中的内容,因为我也无法使用符号链接。

1 个答案:

答案 0 :(得分:7)

错误消息本身告诉您可用的库路径是什么。您无法打印它们,因为您期望在编译时错误之前执行运行时操作(say)–您可以在编译时打印出$*REPO,但同样已经有例外向您展示您想要的东西。

$ 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>

您可以看到/GitHub/perl6-Units/lib出现在可用路径中,这与您的示例不同。我想问一下您的shell / env是否设置正确。