Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Get CPAN to work with passive FTP UNIX
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.
    •    
  • Currently 2.36 / 5
  You rated: 3 / 5 (11 votes cast)
 
[9,308 views]  

Get CPAN to work with passive FTP | 8 comments | Create New Account
Click here to return to the 'Get CPAN to work with passive FTP' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Get CPAN to work with passive FTP
Authored by: revision29 on Jul 17, '09 12:07:10PM

This is awesome. I ended up using Centos in a VM so I could do some perl development because I could not get CPAN to work. I guess I was too lazy to dig into the issue.



[ Reply to This | # ]
don't use CPAN for /usr/bin/perl
Authored by: mzs on Jul 17, '09 12:35:38PM

I'm not sure whether you are or are not, but it is worth a warning.

Only use it with a perl you install somewhere else. Apple updates the perl installation under /usr and you do not want to modify that yourself or else things will get mismatched and you will end-up with a broken system perl installation that is hard to fix.



[ Reply to This | # ]
don't use CPAN for /usr/bin/perl
Authored by: CarlRJ on Jul 17, '09 02:55:37PM
Only use it with a perl you install somewhere else. Apple updates the perl installation under /usr and you do not want to modify that yourself or else things will get mismatched and you will end-up with a broken system perl installation that is hard to fix.

I disagree. Actually, Apple installs all their Perl modules under /System/Library/Perl, and configures Perl specifically so that user-installed modules (such as from CPAN) will install into /Library/Perl. I've been using it this way since Jaguar, and don't recall any significant problems.

One caveat, rather than doing the usual make modulename from the CPAN shell, I do a get modulename instead, and then (outside of the CPAN shell) I cd into the corresponding directory under ~/.cpan/build and, instead of the customary perl Makefile.PL, I do "perl Makefile.PL INSTALLBIN=/usr/local/bin INSTALLSCRIPT=/usr/local/bin INSTALLSITEMAN1DIR=/usr/local/man/man1 INSTALLSITEMAN3DIR=/usr/local/man/man3", in order to get man pages and such to go under /usr/local, following this with the usual make, and make test, and sudo make install. This may be overkill, as a) I haven't looked at the details in a while, but b) I tend to be a control freak about what gets installed and where.

I agree that normally one should not mess with Apple-supplied directories/files, but in this case, it's pretty clear that they intended user-installed Perl modules to go into /Library/Perl.



[ Reply to This | # ]
don't use CPAN for /usr/bin/perl
Authored by: mzs on Jul 20, '09 08:30:38AM
That's all great in theory but in practice it does not work:

http://www.macosxhints.com/article.php?story=20090219082024982

http://www.theregister.co.uk/2009/02/16/apple_update_perl_breakage/

There is blame to go around to all parties (like doing what you say is essentially impossible do to the way module paths work in perl) but the rule of thumb is that for the system installation of perl, only use the vendors packages for that (that goes for linux distros as well) and use another perl install for everything else. The main reason for this is all the perl scripts that are from your vendor which you do not want to break with a newer unexpectedly incompatible version of something or other.

[ Reply to This | # ]
don't use CPAN for /usr/bin/perl
Authored by: CarlRJ on Jul 21, '09 12:53:37AM
That's all great in theory but in practice it does not work ... There is blame to go around to all parties (like doing what you say is essentially impossible do to the way module paths work in perl)

Uh, look, are you sure you understand the definitions of the words "theory" and "practice"? I've been using Perl this way for the past half dozen years (on the Mac, that is -- I've been programming in Perl on various platforms since the early 90's) and it has been working just fine for me in practice. I'm not looking to have an argument, but please don't tell me that something I have been doing can't be done.



[ Reply to This | # ]
don't use CPAN for /usr/bin/perl
Authored by: robleach on Jul 20, '09 10:21:36AM

Thanks for the tip. I haven't had any problems. I used to maintain a separate perl installation, but deviated from that awhile back with my newest computer. I personally don't see a whole lot of risk, but I'll agree that your suggestion is a good thing and could prevent problems.

Note, if you have your perl command aliased or your separate perl install is earlier in your path than apple's, you may use my hint as written. Note thought that if you use sudo, the alias/PATH of the super user is the one that will be used, so it would be easiest to supply the absolute path to your own perl installation.

Rob



[ Reply to This | # ]
Get CPAN to work with passive FTP
Authored by: pub3abn on Jul 20, '09 06:04:01AM

Thanks, I had this problem as well, and I hope this solution fixes it.



[ Reply to This | # ]
Get CPAN to work or try ActiveState instead
Authored by: books on Jul 27, '09 11:51:12PM

We have 40+ Macs all using Perl. When we need to update Perl or load a new module from CPAN, it has to be a quick procedure and must happen concurrently on all Macs.
We had many problems using CPAN over the years and tried various fixes like the one mentioned in this hint. But the worst is that each Mac needed it's own adjustments - there was never a single solution to fit all.

Finally we move to ActiveState Perl (which we knew from our Windows machines) and now Perl works and updates flawlessly. I recommend it for all Perl users on Mac.





[ Reply to This | # ]