请问@INC 的 perl6 等价物是什么?
What is the perl6 equivalent of @INC, please?
我去
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";
来查看在抛出错误之前搜索库的路径。使用 say flat $*REPO.repo-chain.map(*.loaded);
要么是在加载之前,要么是在抛出异常之后。
任何帮助将不胜感激 - 或者可能是关于要放入什么的提示 ~/.perl6
因为我也无法使用符号链接。
错误消息本身告诉您可用的库路径是什么。您无法打印它们,因为您期望在编译时错误之前发生 运行 时间操作( 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 是否真的设置正确。
我去
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";
来查看在抛出错误之前搜索库的路径。使用 say flat $*REPO.repo-chain.map(*.loaded);
要么是在加载之前,要么是在抛出异常之后。
任何帮助将不胜感激 - 或者可能是关于要放入什么的提示 ~/.perl6
因为我也无法使用符号链接。
错误消息本身告诉您可用的库路径是什么。您无法打印它们,因为您期望在编译时错误之前发生 运行 时间操作( 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 是否真的设置正确。