Search code examples
perlcpan

Issues installing Perl modules manually


I'm trying to install the DateTime module on my system. I'm using this guide.

First up I just used wget to download, untarred, did a perl Makefile.pm, and then make

I then ran in to problems with dependencies and saw I could use CPAN instead.

Running install DateTime in cpan seemed to work, and if I try to install it again I get DateTime is up to date (1.51).

The issue though is that now when I try to run my script I get Can't locate namespace/autoclean.pm in @INC, and trying to install that via cpan results in failures like: Warning: no success downloading '/root/.cpan/sources/authors/id/n/n/n/na/namespace/autoclean.pm.tmp28533'. Giving up on it. at /usr/share/perl5/CPAN/Distribution.pm line 379

Is there something I'm missing? Did I screw up my install by trying to install Datetime via wget instead of cpan?


Solution

  • You didn't show what command you issued, but it wasn't correct.[1] cpan was trying to download

    authors/id/n/n/n/na/namespace/autoclean.pm
    

    (autoclean.pm by CPAN author "namespace".)

    The correct file is

    authors/id/E/ET/ETHER/namespace-autoclean-0.29.tar.gz
    

    (namespace-autoclean-0.29.tar.gz by CPAN author "ETHER".)

    The correct shell command is

    cpan namespace::autoclean
    

    From within the cpan interactive interface, the correct command is

    install namespace::autoclean
    

    1. I think you did the equivalent of

      cpan namespace/autoclean.pm
      

      When you provide a path, it's expected to be a path to a distribution, including the author ID. For example, you could use the following to install a specific version of the distribution:

      cpan ETHER/namespace-autoclean-0.29.tar.gz
      

      Note that newer versions of cpan first check if the path corresponds to a known module, so cpan namespace/autoclean.pm would actually have worked for newer versions of cpan.