views:

145

answers:

1

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.
+2  A: 

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.

/I3az/

draegtun
I have my `env` `http_proxy` set. This is the first time I install `perlbrew`. I'm not sre what to do with `HTTP::Lite`...
David B
What version of perlbrew are you using? That line I mentioned above hasn't always been there :( You can check by doing `grep http_proxy ~/perl5/perlbrew/bin/perlbrew`. The latest version of perlbrew is 0.10
draegtun
Just checked commit history on Github and the ENV http_proxy line was only added at version 0.9 on 3rd August. So upgrading to latest version should fix your problems (touch wood!)
draegtun
I think I'm using the latest, just downloaded it a couple of says ago. `grep http_proxy ~/perl5/perlbrew/bin/perlbrew` gives `$ua->proxy($ENV{http_proxy}) if $ENV{http_proxy};`
David B
Fingers crossed its the `http://` bug in the proxy code of `HTTP::Lite`! See my update.
draegtun
+1 draegtun, I followed your instructions and it seems to work. So should I change my env proxy somehow? When I use my Ubuntu Preferences->Network Proxy the proxy is written without any `http://` (but when I `echo $http_proxy` it's with `http://`. So, what should I do -- and will this (what I should do...) might affect other stuff?
David B
@David B: Yes I'm not sure of the side effects of changing http_proxy env on other things. However you can safely do the following each time with no side effects: `http_proxy=IPaddress:Port perlbrew ...`. This only sets the env variable for the command that follows it. So can use this until `HTTP::Lite / perlbrew` is fixed? Or alternatively add `$ENV{http_proxy}="IPaddr:Port"` to you `perlbrew` script locally.
draegtun
@draegtun Nice catch, the proxy solved it. Thanks!
David B