jkeenan1 has asked for the wisdom of the Perl Monks concerning the following question:

This is a two-part question on the use of CPAN.pm as invoked by perl -MCPAN -e shell. The first part discusses a persistent problem for me; the second discusses a problem I observed only for the first time tonight.

First: On my Windows box at work, the CPAN shell installs modules (at least those without XS) lickety-split, no problemo. Likewise on my Linux box. But on my iBook (Darwin 10.3, Perl 5.8.4) -- which has become my primary development tool -- it takes forever, and does so every time I go to use it.

Tonight I was trying to install Spork. Tried to install it manually at first, then got caught by two prerequisites. So I figured I'd try the shell.

cpan> install Spork CPAN: Storable loaded ok Going to read /Users/jimk/.cpan/Metadata Database was generated on Mon, 07 Feb 2005 23:44:07 GMT CPAN: LWP::UserAgent loaded ok Fetching with LWP: ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz

At this point, a pause of more than 5 minutes ensued. And this always happens.

LWP failed with code[400] message[FTP return code 000] Fetching with Net::FTP: ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz Couldn't fetch 01mailrc.txt.gz from ftp.perl.org

More time passed. I went to the bathroom and shaved.

Issuing "/usr/bin/ftp -n" Trying 207.45.221.24... Connected to ftp.cpan.ddns.develooper.com. 220 mirror.teleglobe.net server ready

Only now did things speed up. Allow me to skip ahead to what I think is the next relevant part of the output.

200 Type set to I. local: 01mailrc.txt.gz remote: 01mailrc.txt.gz 500 EPSV not understood. 227 Entering Passive Mode (207,45,221,24,231,210). 150 Opening BINARY mode data connection for 01mailrc.txt.gz (100125 by +tes) 100% |*************************************| 97 KB 212.80 KB/s +00:00 ETA 226 Transfer complete. 100125 bytes received in 00:00 (189.75 KB/s) 221-Goodbye from mirror.teleglobe.net hosted in Newark, NJ 221 GOT /Users/jimk/.cpan/sources/authors/01mailrc.txt.gz Going to read /Users/jimk/.cpan/sources/authors/01mailrc.txt.gz CPAN: Compress::Zlib loaded ok Issuing "/usr/bin/ftp -n" Trying 207.45.221.24... Connected to ftp.cpan.ddns.develooper.com. 220 mirror.teleglobe.net server ready

And skipping ahead again:

local: 02packages.details.txt.gz remote: 02packages.details.txt.gz 500 EPSV not understood. 227 Entering Passive Mode (207,45,221,24,202,125). 150 Opening BINARY mode data connection for 02packages.details.txt.gz +(369742 bytes) 100% |*************************************| 361 KB 385.93 KB/s +00:00 ETA 226 Transfer complete. 369742 bytes received in 00:00 (369.14 KB/s) 221-Goodbye from mirror.teleglobe.net hosted in Newark, NJ 221 GOT /Users/jimk/.cpan/sources/modules/02packages.details.txt.gz Going to read /Users/jimk/.cpan/sources/modules/02packages.details.txt +.gz Database was generated on Tue, 21 Jun 2005 05:57:41 GMT Issuing "/usr/bin/ftp -n" Trying 207.45.221.24... Connected to ftp.cpan.ddns.develooper.com. 220 mirror.teleglobe.net server ready

Are the long delays I'm experiencing due to the fact that ftp.perl.org is the first place my shell looks? Or are the delays due to LWP::UserAgent and Net::FTP, which never seem to work?

2. As I said at the outset, I was trying to install Spork. Once I finally made a connection, this was the output I got:

GOT /Users/jimk/.cpan/sources/modules/03modlist.data.gz Going to read /Users/jimk/.cpan/sources/modules/03modlist.data.gz Going to write /Users/jimk/.cpan/Metadata Running install for module Spork Running make for I/IN/INGY/Spork-0.20.tar.gz mkdir /Users/jimk/.cpan/sources/authors/id/I/IN: Permission denied at +/usr/local/lib/perl5/5.8.4/CPAN.pm line 2342

AFAICR, this was the first time I ever encountered this error. The relevant section of CPAN.pm reads as follows:

sub localize { .... my($aslocal_dir) = File::Basename::dirname($aslocal); File::Path::mkpath($aslocal_dir); # line 2342 $CPAN::Frontend->mywarn(qq{Warning: You are not allowed to write i +nto }. qq{directory "$aslocal_dir". I\'ll continue, but if you encounter problems, they may be due to insufficient permissions.\n}) unless -w $aslocal_dir;

Can anyone diagnose either problem? TIA.

Jim Keenan

Replies are listed 'Best First'.
Re: Why is the CPAN shell not DWIMming?
by Anonymous Monk on Jun 22, 2005 at 02:40 UTC
    Reconfigure CPAN to use a faster mirror
      Seconded. ftp.perl.org is badness. Get a better one.
Re: Why is the CPAN shell not DWIMming?
by Intrepid (Curate) on Jun 22, 2005 at 13:43 UTC
    jkeenan1 wrote:
    Are the long delays I'm experiencing due to the fact that ftp.perl.org is the first place my shell looks? Or are the delays due to LWP::UserAgent and Net::FTP, which never seem to work?

    The long delays are due to the failures of LWP::UserAgent and Net::FTP. CPAN will continue to try those approaches to retrieving the needed files from the mirror host until the lengthy failure timeouts are reached, then will (as reported) fall back to a less sophisticated means. The intelligence to "observe" the previous failures is not part of CPAN, and this is the most frequent valid complaint I hear from Perl users about that software. Note please the qualifiers: frequent and valid. There are numerous other complaints, some of which I regard as not valid (they seem based on what are to me, expectations of the software that are not part of the stated interface, goals or point of the system); and there are other less-frequently raised complaints that I regard as valid.

      Intrepid wrote:

      The long delays are due to the failures of LWP::UserAgent and Net::FTP. CPAN will continue to try those approaches to retrieving the needed files from the mirror host until the lengthy failure timeouts are reached, then will (as reported) fall back to a less sophisticated means.

      Let me provide some more data that may provide experienced monks with a clue to the solution.

      Once I solved the permissions problem (see other posting), I tackled the question of the mirror I was using. I studied the documentation in CPAN.pm and learned that I could define preferences by making changes in $HOME/.cpan/CPAN/MyConfig.pm. I discovered that I had no such file, perhaps because I had never attempted to make configuration changes since installing 5.8.4. So I copied over /usr/local/lib/perl5/5.8.4/CPAN/Config.pm and, after some trial and error, added the following values:

      I'd used all three of these mirrors previously. I then decided to test this configuration by installing a module with relatively few prerequisites and no .XS: brian d foy's Test::Data. To my chagrin, I experienced the same type of delays I'd experienced with ftp.perl.org.

      Only after failing with both LWP::UserAgent and Net::FTP on each of the three mirrors did CPAN.pm finally do the right thing:

      Issuing "/usr/bin/ftp -n" Connected to shadow.cc.columbia.edu. 220- WELCOME to the FTP archives at mirror.cc.columbia.edu ...

      ... at which point the installation went like a bat outta hell. This is consistent with what Intrepid reported he has seen.

      The one new datum I'd like to add is this: I experience similarly long delays when using ftp on my iBook -- but I don't when using it on my Linux or Windows boxes. Suppose I'm ftp-ing to my own web space:

      ftp> cd Storage 250 CWD command successful. ftp> ls 229 Entering Extended Passive Mode (|||57117|) 500 Illegal EPRT command 200 PORT command successful

      I know from experience that at ls or dir, the service will hang and in all likelihood time out -- as it did just now as I was testing it. This was the outcome:

      421 Service not available, remote server timed out. Connection closed

      It's the Extended Passive Mode I'm suspicious of. I don't get that on my other boxes; I get plain Passive Mode on those.

      I posted this problem on the ny.pm mailing list earlier this year, and Ben Holtzman turned me on to the program lftp written by a Russian hacker and available (I think) on Sourceforge. I have no problem using lftp (or, for that matter, the Mac ftp client Fetch) ... except when I have a script that uses Net::FTP.

      So I'm wondering if the problem is not with ftp.perl.org but with the version of ftp that comes with Mac OS X. But if that's the case, why did /usr/bin/ftp -n succeed where LWP::UserAgent and Net::FTP failed?

      It just gets more mysterious!

      jimk

A reply falls below the community's threshold of quality. You may see it by logging in.