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

Oh, monks!

I have an issue with the CPAN shell that has lasted for some time, but it makes installation using the shell something that takes many hours, so it is rather irritating... Especially now that I'm a terrible hurry...

If I go install What::Ever, the shells starts to download, and tries one method, which fails, usually after a long timeout, then goes on to try another, which fails too, then another untill it has exhausted all methods. Then, it tries the next mirror in my mirror list. The same thing happens, it goes on to try the different methods, and after a few timouts, the next mirror. Untill, all of a sudden, it works, and after a few seconds, the module is installed and working.... I can't see any pattern in why it suddenly works, but apparently is does learn something about what doesn't work, and skips some methods after a while. But I can't really see any pattern in that either...

So, it isn't that it doesn't work at all, just that it often takes an hour with all these things about failing fetch methods...

This is an example output:

Fetching with LWP: ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/01mailrc.txt.gz LWP failed with code[400] message[FTP return code 000] Fetching with Net::FTP: ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/01mailrc.txt.gz Couldn't fetch 01mailrc.txt.gz from ftp.funet.fi Fetching with LWP: ftp://ftp.du.se/pub/CPAN/authors/01mailrc.txt.gz LWP failed with code[400] message[FTP return code 000]
LWP works great with other modules, so I can't imagine it being at fault...

Have anybody else seen this behaviour?

If not, is there a way I can set the timeout to some small value, so at least the process is faster?

Replies are listed 'Best First'.
Re: Problems accessing CPAN with the shell
by liz (Monsignor) on Dec 11, 2003 at 18:50 UTC
    This fixes the problem for me. Do a:
    export FTP_PASSIVE=1
    before starting the CPAN shell. From the Net::FTP documentation:

    Passive - If set to a non-zero value then all data transfers will be done using passive mode. This is not usually required except for some dumb servers, and some firewall configurations. This can also be set by the environment variable FTP_PASSIVE.

    Liz

      I had the very same issue with my cpan shell, and what do you know, passive mode did the trick. Thank you very much, now I can get back to worry about real issues :) -- Take
Re: Problems accessing CPAN with the shell
by jmanning2k (Pilgrim) on Dec 11, 2003 at 16:15 UTC
    Are you behind a proxy or firewall of any sort? Can you ftp normally using ftp or wget?

    Can you show us the output of the command o conf from the CPAN shell?

    Not the ideal solution, but to answer your question about reducing these other timeouts: I suspect unsetting ftp, ncftp, ncftpget, wget and lynx will prevent it from using these other methods and only use LWP. Try doing o conf ftp '' for each of these options.

    ~J

    Update:Have you tried a http mirror?

      No proxy. I've got IPTables running on all machines, but the OUTPUT chain is open. Normal ftp and everything is working well. Here's an output from o conf (on a different machine than before, but they both have the same problem):
      cpan> o conf CPAN::Config options from /etc/perl/CPAN/Config.pm: commit Commit changes to disk defaults Reload defaults from disk init Interactive setting of all options build_cache 10 build_dir /var/cache/cpan/build cache_metadata 1 cpan_home /var/cache/cpan/ cpan_version_check 1 dontload_hash ftp /usr/bin/ftp ftp_proxy getcwd cwd gpg /usr/bin/gpg gzip /bin/gzip histfile /var/cache/cpan/histfile histsize 100 http_proxy inactivity_timeout 0 index_expire 1 inhibit_startup_message 0 keep_source_where /var/cache/cpan/sources lynx /usr/bin/lynx make /usr/bin/make make_arg make_install_arg makepl_arg ncftpget /usr/bin/ncftpget no_proxy pager /usr/bin/less prerequisites_policy ask scan_cache atstart shell /bin/bash tar /bin/tar term_is_latin 1 unzip /usr/bin/unzip urllist ftp://ftp.uninett.no/pub/languages/perl/CPAN ftp://ftp.funet.fi/pub/languages/perl/CPAN/ ftp://ftp.uit.no/pub/languages/perl/cpan/ ftp://ftp.du.se/pub/CPAN/ wget /usr/bin/wget
      Actually, it is ncftpget, wget and lynx CPAN falls back to after a trail and error period with LWP and Net::FTP. Not that I really think LWP is any worse, but it is not any better either.

      As for HTTP mirrors, I haven't tried one, when you ask. I'll add one and see what happens. Update: No improvement using a HTTP mirror.

        If LWP and Net::FTP are failing, but the command line tools are working, try this command in a CPAN shell.
        o conf dontload_hash "{ 'Net::FTP' => 1, 'LWP::UserAgent' => 1 }"

        This should make it skip the perl modules and jump right to the command line tools.

        My next step would probably be to reinstall LWP and Net::FTP. Perhaps newer versions or a reinstall will fix the issues you are having. Or, just be happy with wget, ncftpget, and lynx.

        ~J

        Update: Don't forget to do a o conf commit to save the CPAN config changes for future sessions.

Re: Problems accessing CPAN with the shell
by shenme (Priest) on Dec 11, 2003 at 18:28 UTC
    I have had this problem in times past when connected to the network in a way that prevented FTP connections from working, specifically FTP data connections. Testing FTP by connecting to a site isn't sufficient, you have to try downloading from the site.

    Anyway, I eventually eliminated all ftp:// URL's from the urllist that CPAN tries and no longer had the problem.

      Hm, now I tried removing all ftp URLs from the URL list, but it certainly did not help me... :-( Strangely, I have no problems wgetting the same URL outside of the cpan shell, but within nothing happens...
Re: Problems accessing CPAN with the shell
by jdtoronto (Prior) on Dec 11, 2003 at 16:06 UTC
    Hi Kjetil,

    Darn it, I have the same problem! But I have been too busy coding here to worry about it. When I am root on my machine and I use the CPAN shell, I have all those problems, it is a nightmare. BUT - when I am another user it all works like a dream. Except that I cannot complete the install phase. I have another terminal open and I go into the module directory and just do the make install there.

    I hope you get some good answers, coz I wanna read em too.
    jdtoronto

      Good to hear I'm not alone in this whole world! For a moment, I thought it was something Evil just around me here... ;-) Keep your eyes on this post, then!