如何使用 perlbrew 在我家安装 Perl 版本?

发布于 2024-09-19 15:52:53 字数 393 浏览 5 评论 0原文

我已经安装了 perlbrew 这似乎是一个很好的解决方案,但我得到实际尝试安装某些 Perl 版本时出现一些无意义的错误:

$ perlbrew install perl-5.12.1
Attempting to load conf from /home/dave/perl5/perlbrew/Conf.pm
Fail to get http://search.cpan.org/dist/perl-5.12.1 (error: ) at /home/dave/perl5/perlbrew/bin/perlbrew line 1277.

I have installed perlbrew which seems like a good solution, but I get some meaningless error when actually trying to install some Perl version:

$ perlbrew install perl-5.12.1
Attempting to load conf from /home/dave/perl5/perlbrew/Conf.pm
Fail to get http://search.cpan.org/dist/perl-5.12.1 (error: ) at /home/dave/perl5/perlbrew/bin/perlbrew line 1277.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘你却要生生世世 2024-09-26 15:52:53

根据您的评论,您的 shell 中是否设置了 http_proxy ENV 变量?

$ env | grep http_proxy

如果没有,则使用您的代理设置进行设置,然后重试 perlbrew 安装:

 $ export http_proxy = "http://yourProxyURLorIP:8080"
 $ perlbrew install perl-5.12.1

perlbrew 使用此 ENV 变量来获取代理服务器。如果未设置此 ENV 变量,则会尝试正常的直接 HTTP 连接(请参阅 Github 上 perlbrew 当前 master 中的第 1274 行

$ua->proxy($ENV{http_proxy}) if $ENV{http_proxy};

如果这不起作用,请查看 HTTP::Lite。这就是 perlbrew 在后台使用的内容来获取源代码。 注意。 perlbrew 使用自己的 HTTP::Lite 副本

最后,如果仍然不走运,您提到您通过 CPAN“首先安装了它”。该文档确实提到了从以前的 CPAN 版本升级时出现的问题。这也许是您需要进一步研究的事情?

更新测试此HTTP::Lite 脚本并让我知道您看到的内容(注意。您可能需要安装 < code>HTTP::Lite):

use strict;
use warnings;
use HTTP::Lite;

my $ua = HTTP::Lite->new;

$ua->proxy("yourProxyURLorIP:8080");  # <= http_proxy env minus "http://"

my $req = $ua->request( 'http://search.cpan.org/dist/perl-5.12.1/' ) 
    or die "Unable to get document: $!";


print $ua->body();   # <= if you get this then all is good!

我认为您可能遇到了 HTTP::Lite,请参阅 RT 问题 uri 样式代理环境变量无法正确设置代理和端口

上面的代码就是这个bug的解决方法。我假设同样的错误存在于 HTTP 的 perlbrew 副本中::精简版。如果是,那么从 http_proxy ENV 中删除 http:// 将解决问题(著名的最后一句话!)

更新2

只是为了让我最后的评论清楚,当你运行perlbrew时,你可以这样做(从像bash这样的shell):

http_proxy=IPaddr:Port perlbrew install perl-5.12.1

你需要始终像这样为每个 perlbrew 命令添加前缀,至少在 HTTP::Liteperlbrew 代理错误修复之前。

上面的替代方法是,您可以只修补本地版本,只需在第 1277 行之前添加以下内容:

$ENV{http_proxy} = "IPaddr:Port";   # <= your proxy IP & port

希望我们终于破解了它!如果一切成功,请告诉我,因为如果是这样,我将向 Gugod的作者)发布修复程序perlbrew),并对 HTTP::Lite 进行必要的本地更改。

Based on your comments do you have http_proxy ENV variable set in your shell?

$ env | grep http_proxy

If not then set it with your proxy settings and re-try perlbrew install:

 $ export http_proxy = "http://yourProxyURLorIP:8080"
 $ perlbrew install perl-5.12.1

perlbrew uses this ENV variable to pick up the proxy server. If this ENV variable isn't set then it tries the normal direct HTTP connection (see line 1274 in perlbrew current master on Github)

$ua->proxy($ENV{http_proxy}) if $ENV{http_proxy};

If that doesn't work then have a look at HTTP::Lite. This is what perlbrew uses under the hood to fetch source code. NB. perlbrew uses its own copy of HTTP::Lite

Finally if still no luck you mentioned that you "first installed it" via CPAN. The docs does mention issues when upgrading from a previous CPAN version. This maybe something further you need to look into?

Update Test this HTTP::Lite script and let me know what you see (NB. You may need to install HTTP::Lite):

use strict;
use warnings;
use HTTP::Lite;

my $ua = HTTP::Lite->new;

$ua->proxy("yourProxyURLorIP:8080");  # <= http_proxy env minus "http://"

my $req = $ua->request( 'http://search.cpan.org/dist/perl-5.12.1/' ) 
    or die "Unable to get document: $!";


print $ua->body();   # <= if you get this then all is good!

I think you've probably been hit by a known bug with HTTP::Lite, see RT issue uri style proxy env vars fail to set the proxy and port correctly.

The above code is the workaround to this bug. I assume the same bug is in perlbrew copy of HTTP::Lite. If it is then removing the http:// from your http_proxy ENV would resolve the problem (famous last words!)

Update 2

Just to make my last comment clear when you run perlbrew you can do this (from shell like bash):

http_proxy=IPaddr:Port perlbrew install perl-5.12.1

You would need to always prefix every perlbrew command like this, at least until HTTP::Lite or perlbrew proxy bug is fixed.

Alternative to above is you can just patch your local version just be adding the following before line 1277:

$ENV{http_proxy} = "IPaddr:Port";   # <= your proxy IP & port

Hopefully we've finally cracked it! Let me know if all successful because if so then I'll post a fix to Gugod (author of perlbrew) with necessary local changes to HTTP::Lite.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文