开发者

How can I install Perl version under my home using perlbrew?

开发者 https://www.devze.com 2023-01-16 10:40 出处:网络
I have installed perlbrew wh开发者_开发百科ich seems like a good solution, but I get some meaninglesserror when actually trying to install some Perl version:

I have installed perlbrew wh开发者_开发百科ich 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消