14

I'm wondering if anyone can help me. I installed CPAN.pm via command line and then tried installing a module via CPAN. But I encountered an error:

Can't call method "http" on unblessed reference at /usr/lib/perl5/5.10.0/CPAN/FirstTime.pm line 1866.
peterh
  • 11,875
  • 18
  • 85
  • 108
icasimpan
  • 1,253
  • 3
  • 16
  • 28
  • 1
    "Installed CPAN"? CPAN is a core module. – TLP Mar 08 '12 at 07:58
  • @TLP Yes, it's CPAN that I installed from command line first coz it seems that it wasn't part of the system I'm maintaining (fedora11). I compiled/installed it from source then tried installing a module through it. That's then that I encountered the error I highlighted. Take note that my http_proxy is set so there's no problem with my internet connection – icasimpan Mar 08 '12 at 08:28
  • You need to show us what you did on the command line. – brian d foy Mar 08 '12 at 19:40

5 Answers5

9

This error can be resolved by entering the username and password fields in the proxy that cpan uses. 1] First Install cpan by

sudo yum install perl-CPAN

2] Then run the following command

cpan

It asks for setting basics, then select "NO" option for automatically picking then keep pressing enter till you are asked for "Automatically connect to internet", press no.

3] Then you will be asked for mirror details keep selecting from the list that it provided.

4] Then set the proxy username and password fields

5] Installation will then be complete and it will take you to cpan> prompt like below

cpan>

6] In the prompt enter

install Bundle::LWP
Joao Vitorino
  • 2,976
  • 3
  • 26
  • 55
Guru
  • 2,739
  • 1
  • 25
  • 27
7

Firstly I'm surprised that CPAN isn't already installed as it has been part of the standard Perl distribution since Perl 5.004 was released fifteen years ago.

Secondly I'm surprised that you're still using Fedora 11. That version has been unsupported since June 2010.

Thirdly, I'm surprised that you want to use CPAN.pm as CPANPLUS and cpanminus are both far better interfaces to CPAN.

But given all of those surprises, if you want CPAN on your system, the best approach is probably to use the one that the Fedora project have pre-built for you.

$ sudo yum install perl-CPAN

There will be a number of CPAN modules available pre-build from Fedora. You can see them all using:

$ yum list available perl-\*

You'll find even more available for recent versions of Fedora.

You can almost certainly get CPANPLUS by installing perl-CPANPLUS. I doubt whether cpanminus is available for such an old version of Fedora.

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
  • your suggestion to do 'yum install perl-CPAN' worked for me. Thanks :) – icasimpan Mar 08 '12 at 10:12
  • But please take notice of my other suggestions too. 1/ Upgrade to a supported version of Fedora. 2/ Use CPANPLUS or cpanminus in preference to CPAN. – Dave Cross Mar 08 '12 at 10:34
  • I will take note of your suggestion for CPANPLUS or cpanminus. I'm fairly new to Perl so that helps. As to your suggestion to upgrade to a supported Fedora version, I'm not at a liberty to do that. The development team in our company dictates which distro/version to use. – icasimpan Mar 09 '12 at 06:23
  • 1
    If the people in your company who make those kinds of decisions don't care about using unsupported software then I strongly suggest that you start looking for somewhere else to work. – Dave Cross Mar 09 '12 at 07:20
  • I'm afraid you misunderstood my point. The developers in our company choose the said distro since it's the only distro they used to develop linux code that works across other distro. – icasimpan Mar 09 '12 at 08:09
  • I think you misunderstand my point. The problem is not with your distribution. Fedora is a fine distribution - I use it for al of my Perl development. The problem is with the version of Fedora you are using. Fedora 11 has been completely unsupported since June 2010. You should be using Fedora 15 or 16 at this point. – Dave Cross Mar 09 '12 at 09:33
  • Yup, I'm fully aware that Fedora 11 is outdated and I don't think we need to argue on that :) – icasimpan Mar 12 '12 at 01:55
  • Thanks for the suggestion to use cpanminus - this fixed my issue trying to install URI::Escape on an AmazonLinux docker container. – Grant Lay Aug 17 '20 at 03:07
6

I just had the same issue while installing Perlbrew.

After doing some debugging, I found out that this error happens because the CPAN logic could not find a mirror candidate. Of course, this could be improved in the CPAN::Mirrors or CPAN::FirstTime by just checking the results returned by the related functions.

Since those are not checked (and thus assumed that always returns some value) I got this meaningless error. But I must say I didn't checked further to see why no value is being returned after all.

You can safely avoid this error by simply selection No as answer for the automatic configuration. Of course, you will need to reply for each one of the configuration directives.

I got this while installing perl 5.16.3 thru perlbrew.

user3253562
  • 61
  • 1
  • 1
0

I had the same error, and did not have root privileges. The problem lay with there being two versions of cpan installed:

  • /usr/bin/cpan
  • /usr/local/bin/cpan

When I specified the former, things began to work.

0

replace Config.pm with fixed vertion

wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/CPAN-2.16.tar.gz
tar -zxvf CPAN-2.16.tar.gz
sudo mkdir  /usr/share/perl5/CPAN/ -p
sudo cp ./CPAN-2.16/lib/CPAN/FirstTime.pm /usr/share/perl5/CPAN/FirstTime.pm

source

Mohannd
  • 1,288
  • 21
  • 20