Get CPAN to work with passive FTP

Jul 17, '09 07:30:54AM

Contributed by: robleach

I don't know if this is already common knowledge, but it's been an irritation to me for some time and I finally figured it out. Whenever I tried to use CPAN to install Perl modules in Mac OS X, I would always get a never ending series of long waits and error messages akin to:

Fetching with LWP:
  ftp://xxx/pub/CPAN/authors/01mailrc.txt.gz
LWP failed with code[404] message[File '01mailrc.txt.gz' not found]
Fetching with Net::FTP:
  ftp://xxx/pub/CPAN/authors/01mailrc.txt.gz
Couldn't fetch 01mailrc.txt.gz from carroll.cac.psu.edu
When I searched for the error messages, all the top hits lead to the same question others had with no responses. Finally, I kept digging and tweaking my search parameters until I found a solution that worked. You need to set an environment variable to tell CPAN to use passive FTP mode. I have aliased this so that I never need to think about it again:
env FTP_PASSIVE=1 perl -MCPAN -e shell
If you type that into the command line, CPAN will finally work correctly. Don't forget that you may need to sudo the command.

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090716132354455