gpt4 book ai didi

macos - Perlbrew 找不到 @INC

转载 作者:行者123 更新时间:2023-12-04 01:01:05 28 4
gpt4 key购买 nike

我认为 perlbrew 已正确安装并使用正确的@INC。我切换到 perlbrew。我想要的模块( String::Approx )已安装。我有资源 ~/perl5/perlbrew/etc/bashrc~/.bash_profile .
但我收到错误 Can't locate String/Approx.pm in @INC :

$ which perl
/Users/kip/perl5/perlbrew/perls/perl-5.33.9/bin/perl
$ perlbrew info
Current perl:
Name: perl-5.33.9
Path: /Users/kip/perl5/perlbrew/perls/perl-5.33.9/bin/perl
Config: -de -Dprefix=/Users/kip/perl5/perlbrew/perls/perl-5.33.9 -Dusedevel -Aeval:scriptdir=/Users/kip/perl5/perlbrew/perls/perl-5.33.9/bin
Compiled at: May 3 2021 10:04:48

perlbrew:
version: 0.92
ENV:
PERLBREW_ROOT: /Users/kip/perl5/perlbrew
PERLBREW_HOME: /Users/kip/.perlbrew
PERLBREW_PATH: /Users/kip/perl5/perlbrew/bin:/Users/kip/perl5/perlbrew/perls/perl-5.33.9/bin
PERLBREW_MANPATH: /Users/kip/perl5/perlbrew/perls/perl-5.33.9/man
$ perlbrew list-modules
App::cpanminus
PerlIO::gzip
String::Approx
install
$ perl -E 'say for @INC'
/Users/kip/perl5/perlbrew/perls/perl-5.33.9/lib/site_perl/5.33.9/darwin-2level
/Users/kip/perl5/perlbrew/perls/perl-5.33.9/lib/site_perl/5.33.9
/Users/kip/perl5/perlbrew/perls/perl-5.33.9/lib/5.33.9/darwin-2level
/Users/kip/perl5/perlbrew/perls/perl-5.33.9/lib/5.33.9
这是我尝试运行脚本时的特定错误消息(为便于阅读而格式化)。看起来系统@INC 仍在搜索中?
Can't locate String/Approx.pm in @INC (you may need to install the String::Approx module) 
(@INC contains: /Library/Perl/5.30/darwin-thread-multi-2level
/Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level
/Network/Library/Perl/5.30
/Library/Perl/Updates/5.30.2
/System/Library/Perl/5.30/darwin-thread-multi-2level
/System/Library/Perl/5.30
/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level

/System/Library/Perl/Extras/5.30) at ./myScript.pl line 21.

最佳答案

运行myscript.pl./myscript.pl似乎正在使用系统 perl (v5.30)。也许该文件中有一个指向系统 perl 的 shebang 行。如果是这种情况,请调用 ./myscript.pl将始终引用 shebang 行中指定的程序,而不是 perlbrew已将您的环境设置为。
解决方案:

  • 使用perl显式调用脚本
    $ perl myscript.pl    # this
    $ ./myscript.pl # and not this
  • 更新您的 shebang 行以使用“当前”perl .其中一项或多项可能有效:
    #!perl
    #!/usr/bin/env perl
  • 关于macos - Perlbrew 找不到 @INC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68231484/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com