5

Here is my problem. I am running OS X v10.7 (Lion) and want to set up an old Perl program I have written (was then using a Windows System with ActivePerl and then its ppm).

I read to use CPAN to install Perl modules (I am trying to install the Graph module). Whenever I tried to install it, it failed from a refused connection. Why? So I read that I should run the following to update CPAN and fix any broken links:

cpan> install Bundle:CPAN
cpan> reload cpan
cpan> index cpan
cpan> exit

However, after doing this I am stuck with this every time I try to do a CPAN install or upgrade:

New CPAN.pm version (v1.9800) available.
  [Currently running version is v1.9456]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.

I was trying to use the default Perl stuff that is included in OS X rather than downloading ActivePerl. How do I fix CPAN and install the Graph Module?

PS: Running install CPAN and reload CPAN didn't do anything, but it generated the same message.

UPDATE I was able to upgrade to v1.9800 doing a manual install (make, install) through the terminal. But I am still unable to install the Graph Module. Here is what I am getting:

http://cloud.jjnford.com/3D1C1H4217222b1p1O3a

UPDATE - PROBLEM SOLVED I was finally able to solve the problem. I just moved the /User/jj/.cpan directory to User/jj/.cpan_bak and then reconfigured CPAN and the Graph Module installed with no fuss.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jjNford
  • 5,170
  • 7
  • 40
  • 64
  • Which version of Perl are you using? Are you updating the system-provided Perl, or one of your own building? – Jonathan Leffler Feb 05 '12 at 06:56
  • @Jonahan I am using the system-provided version of Perl. I was able to solve the problem by doing a manual CPAN install and reconfiguring it. Probably just and issue with the older version and Lion. Thanks for your interest though. – jjNford Feb 05 '12 at 06:59
  • Be cautious about changing the system installation. I haven't specifically heard of a Perl module upgrade breaking things, but I long ago decided that it was safer to leave the system Perl well alone, and to only modify the modules in versions of Perl built by me and installed separately from the system Perl. Maybe that's (ouch!) 15-year old paranoia. But I either use the system Perl unchanged or use my 'home-built' Perl; I don't risk modifying the system Perl. – Jonathan Leffler Feb 05 '12 at 07:45
  • @jjNford - By all means, feel free to post your solution as an answer and accept it. –  Feb 05 '12 at 08:07
  • 1
    @JonathanLeffler - With [perlbrew](http://search.cpan.org/~gugod/App-perlbrew-0.41/lib/App/perlbrew.pm) it's become pretty easy nowadays to either upgrade the core Perl installation or create separate Perl installation in a specified prefix. –  Feb 05 '12 at 08:09
  • @Jack Maney - Thanks, posted my solution just now. – jjNford Feb 05 '12 at 16:28

4 Answers4

5

To solve this problem, do a manual upgrade of CPAN (apparently on OS X CPAN has trouble upgrading itself). You can download the source from here. After you have downloaded it uncompress it, create the make file from the Perl script, then run a make test, and finally if all goes well a make install.

$> tar -xvxf CPAN-1.9800
$> cd CPAN-1.9800
$> perl Makefile.PL
$> make
$> make test
$> make install

Now get rid of your old CPAN configuration:

$> mv ~/.cpan ~/.cpan.bak

Now when you run CPAN from the terminal you should be prompted for the configuration again. Once this is complete and CPAN has started you will notice this:

cpan shell -- CPAN exploration and modules installation (v1.9800)

So CPAN is now upgraded and working, and in my case I installed the Graph Module:

$cpan> install Graph

And everything works fine. I hope this helps somebody.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jjNford
  • 5,170
  • 7
  • 40
  • 64
4

I know this was solved, but do consider using "cpanminus" instead next time. It's faster and could save you a lot of hassle. You can either install App:cpanminus using cpanminus (see: App::cpanminus):

curl -L http://cpanmin.us | perl - --sudo App::cpanminus

And then to install any module and its dependencies simply run:

cpanm <module>

Alternatively you could use it directly from the web:

curl -L http://cpanmin.us | perl - --sudo <module>

I use it on my OS X Lion, and it works perfectly :)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Amir
  • 1,882
  • 17
  • 22
  • Also, I wouldn't change the system's native perl. Consider using [perlbrew](https://metacpan.org/module/perlbrew) – Amir Feb 05 '12 at 08:08
4

I have a fresh Mac OS X Lion and I updated CPAN without problems.

Installing XCode is not enough. Make, gcc, g++ are not installed by default.

To install them, one has to: Start XCode, go to XCode->Preferences->Downloads and install component named "Command Line Tools".

Francesc
  • 41
  • 1
0

Please excuse me for replying to this old post.

I had the same issue as the OP. Once I corrected the command to contain two colons instead of one (i.e. - Bundle::CPAN vs Bundle:CPAN), it worked as expected.