Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

how could use inc::Module::Install ever work? and other M::I questions

by metaperl (Curate)
on Aug 30, 2010 at 16:06 UTC ( #858036=perlquestion: print w/replies, xml ) Need Help??

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

Hello, I emailed the author of Module::Install three days ago and have not heard back. So, I am writing here instead.

how could use inc::Module::Install ever work?

I followed the SYNOPSIS for Module::Install in the Makefile.PL for my project.

However because this Makefile.PL has the (recommended) line: use inc::Module::Install when I run perl Makefile.PL I get:

<metaperl@andLinux:~/prg/dbix-cookbook> perl Makefile.PL Can't locate inc/Module/ in @INC (@INC contains: /etc/perl / +usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 + /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/ +lib/site_perl .) at Makefile.PL line 1. BEGIN failed--compilation aborted at Makefile.PL line 1. <metaperl@andLinux:~/prg/dbix-cookbook>
and that does not surprise me (grin). And the related FAQ entries do not shine any light on my situation.

My goal is to release this to CPAN so that perl -MCPAN -e 'install DBIx::Cookbook' does not choke when running perl Makefile.PL

The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

Replies are listed 'Best First'.
Re: how could use inc::Module::Install ever work? and other M::I questions
by moritz (Cardinal) on Aug 30, 2010 at 16:26 UTC
    how could use inc::Module::Install ever work?

    By having inc::Module::Install installed.

    It's part of the Module-Install distribution.

    My goal is to release this to CPAN so that perl -MCPAN -e 'install DBIx::Cookbook' does not choke when running perl Makefile.PL

    Maybe declaring a configuration dependency on a new version of Module::Install would fix this? (just guessing, I'm more of a Module::Build user)

    Perl 6 - links to (nearly) everything that is Perl 6.

      It wasn't at all clear to me from the module documentation and it still wasn't completely clear from the responses. So, just to stress the points and clarify that they aren't contradicting...

      Like I said, I couldn't find clarification reading the module documentation (Module::Install). But I looked at Makefile.PL to try to verify that inc/Module/ is supposed to get installed when you install Module::Install. I found this encouragement in a comment:

      It causes inc::Module::Install to load from the (unique to this distribution) file ./lib/inc/Module/ instead of the system inc::Module::Install or the bundled /inc/Module/

      So, "use inc::Module::Install;" works when a new module author runs "perl Makefile.PL" because they installed Module::Install which installed inc/Module/ along with Module/ And "use inc::Module::Install;" works when some random person downloads the new module because inc/Module/ gets included in the new module's tar ball (or other archive format).

      To make it even clearer, there are the chronological steps:

      1. New module author decides to use Module::Install for their new module
      2. Author downloads Module-Install tar ball and extracts contents
      3. Author runs "perl Makefile.PL" for Module-Install distribution
      4. Module::Install's Makefile.PL does "use lib 'lib'" then "use inc::Module::Install"
      5. perl finds lib/inc/Module/ that came with the Module-Install distribution
      6. Author eventually runs "make install" which creates inc/Module sub-directory tree under some ...perl.../...lib... where, if the new author didn't make some mistake, perl is already searching for its standard modules and copies into it
      7. Author writes new Makefile.PL for their own module
      8. Author runs "perl Makefile.PL" for the first time
      9. The new Makefile.PL runs "use inc::Module::Include"
      10. perl finds inc/Module/ among its standard modules
      11. inc/Module/ makes inc/Module sub-directory tree under the new module's build directory and copies itself into there
      12. Author makes a distribution and Module::Install has arranged the "manifest" file to list inc/Module/ so that it gets included in the tar ball and uploaded to PAUSE and CPAN
      13. Random user downloads and extract this new module then runs "perl Makefile.PL"
      14. The new module's Makefile.PL runs "use inc::Module::Install"
      15. If the random user has Module::Install installed, then perl will find inc/Module/ among the main modules
      16. If not, then perl will find the one included in the new module's distribution

      That explanation should be more than sufficiently exhaustive. :)

      So, it seems that metaperl didn't install Module::Install correctly.

      - tye        

Re: how could use inc::Module::Install ever work? and other M::I questions
by ikegami (Pope) on Aug 30, 2010 at 16:55 UTC
    Creating the distribution properly (perl Makefile.PL && make dist) will create inc/Module/ and include it in the tarball.
      Doesn't that still need some @INC manipulation to work?
      Perl 6 - links to (nearly) everything that is Perl 6.
        By default, Perl includes "." in @INC, so no.

        I thought you meant from the installer's perspective, not the author's. The author needs to install Module-Install which includes inc::Module::Install.

        When the author runs perl Makefile.PL, it will use the system's inc::Module::Install, and it will copy inc/Module/ locally. The local copy will be included in the distribution when the author runs make dist.

        This differs from ExtUtils::MakeMaker where both the author and the installer need to have ExtUtils::MakeMaker installed.

Re: how could use inc::Module::Install ever work? and other M::I questions
by Khen1950fx (Canon) on Aug 30, 2010 at 23:46 UTC
    I used Module::Install in my last module, along with ExtUtils::MakeMaker. Just start the Makefile.PL with  use inc::Module::Install. Then write your Makefile.PL as you would using MakeMaker. Here's an example.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://858036]
Approved by moritz
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2020-08-14 00:25 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (75 votes). Check out past polls.