2

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.
Ether
  • 53,118
  • 13
  • 86
  • 159
David B
  • 29,258
  • 50
  • 133
  • 186
  • 1
    You get that error when it fails to find/download the Perl source code. So could be internet or firewall issues? – draegtun Sep 15 '10 at 13:58
  • ubuntu 10.04. I have proxy enabled. wget works, also git and cpan (this is how I first installed it). – David B Sep 15 '10 at 16:45
  • 1
    BTW, perl 5.12.2 was released recently: http://news.perlfoundation.org/2010/09/perl-5122-released.html – draegtun Sep 17 '10 at 07:16
  • @draegtun by the way, is there a way to ask perlbrew for a list of perl versions available for install? – David B Sep 17 '10 at 07:42
  • 1
    I don't think `perlbrew` has this option because it just slavishly pulls down the perl you request, for eg `perlbrew install perl-5.12.3` (it would try and give an error until one day 5.12.3 is actually there!). So yes this would be a very nice feature for `perlbrew` to have. In the meantime I just quickly put together this script to get a list of available perl versions: http://gist.github.com/584025 – draegtun Sep 17 '10 at 10:26

1 Answers1

8

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.

AndyG
  • 39,700
  • 8
  • 109
  • 143
draegtun
  • 22,441
  • 5
  • 48
  • 71
  • 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 Sep 16 '10 at 07:21
  • 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 Sep 16 '10 at 07:26
  • 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 Sep 16 '10 at 09:17
  • Fingers crossed its the `http://` bug in the proxy code of `HTTP::Lite`! See my update. – draegtun Sep 16 '10 at 10:42
  • +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 Sep 16 '10 at 16:46
  • @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 Sep 16 '10 at 18:08