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

Hello, dear monks, I have a quick question, and was wondering if you, guys, could help me... Is there a way to install a module using 'cpan' command-line tool from a local tar.gz file, instead of having the cpan thingie download the package from the server? If there's an existing post, I couldn't find it :( Thank you, MB
  • Comment on Install a CPAN module from a local distr. file

Replies are listed 'Best First'.
Re: Install a CPAN module from a local distr. file
by Fletch (Bishop) on Mar 30, 2007 at 19:11 UTC

    If you've got the tarball locally anyhow then there's not really much benefit there in having CPAN install it over just unbundling it by hand and running 'perl Makefile.PL && make && make test && make install' from your shell (which is pretty much just what the install command would have done).

      I've wondered the same thing as the OP. The difference is that CPAN will offer to download and install any dependencies, which can be very convenient if there are more than a few.
      Hmm, I guess I should have stated why I was trying to use CPAN: The aforementioned tarball/package will be submitted to CPAN; What I am trying to do is to ensure that when someone installs that package via CPAN, the pre-reqs will be installed as well (provided that CPAN is configured to do so). I put the pre-req modules in the Makefile.PL, but I wanted to make sure CPAN actually requests those modules; and I wanted to test it _before_ the package is submitted to CPAN. Hope this makes sense... Thanks for the reply, by the way; that's was darn fast :) MB

        Aaah, that makes more sense then. Perhaps setting up your own mirror with CPAN::Mini and using CPAN::Mini::Inject to put your module therein is what you're after?

        (And usually if I'm installing something by hand I've already resolved the dependencies by hand or it doesn't have any; but that was a good point. My brane's mush today . . .)

        If you upgrade to a recent development version of CPAN (anything later than 1.88_55), it supports installing from local directories using a new "dot" syntax for distributions. Give it a dot or end a directory path with a dot and it will use that directory as if it were a downloaded and unwrapped tarball.

        $ cpan . $ cpan some/directory/.

        -xdg

        Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        I updated the CPAN, but the dot (.) trick doesn't work; cpan thinks it's a module name :/ (i've tried "./" as well)
        MB