Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Upgrading Core Modules Using CPAN - Best Practice?

by stocks29 (Acolyte)
on Oct 02, 2008 at 21:13 UTC ( [id://715096]=perlquestion: print w/replies, xml ) Need Help??

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

I am working on upgrading some core modules installed on a solaris machine used for development. I am using the CPAN shell to upgrade these modules.

The problem is that the path that the Makefile(s) wants to install the module(s) to is not the same as the location they are install to when perl is installed. That is, the "CORE" installation path (which I believe is referred to as 'perl') is different than the "CPAN" installation path (which I believe is called 'site'). This leaves us with two versions of the same module installed on the system, meaning that the version being used by applications is determined by the order of @INC, since both locations are in @INC. Currently the "CORE" path appears first, so the newer versions of such modules are not being used.

I came across this post: http://grokbase.com/post/2008/03/18/perl-and-cpan-distributors/qgHek3zF7tvfS9x8R2pwFHtSe0Q which suggests that, when recompiling perl, you set @INC to have the CPAN (or site) paths appear before the CORE (or perl) paths. This seems to make sense since you would expect the CPAN version to (in 99% of cases) be newer than the CORE version. Also, whenever a modules was upgraded the newest version would automatically be used since it would appear first in @INC.

This solution also appears to have the potential to cause issues if developers are modifying @INC in some fashion (manually or using a module) that would cause them to use the older version of the module. In this case, they could be beating their head against a wall for quite some time trying to figure out why they don't have some new functionality provided by the new version.

Another possible solution would be to somehow get the CPAN versions to clobber the CORE versions when they are upgraded. This would solve the problem, but there does not seem to be an easy way to do this. SOME core module Makefile.PLs take arguments that would allow you to change the default install location, but it is not consistent for each module. This means that putting Makefile.PL args in CPAN::Config may work for some modules but not for others. Essentially, in order to be sure, each module would have to be installed manually after having it's Makefile.PL inspected for any such arguments and even this would not work for all modules.

Does anyone know of any best practices in regards to this?

  • Comment on Upgrading Core Modules Using CPAN - Best Practice?

Replies are listed 'Best First'.
Re: Upgrading Core Modules Using CPAN - Best Practice?
by JavaFan (Canon) on Oct 02, 2008 at 21:23 UTC
    I'm a bit surprised by this. Whenever I update a core module (which, admittingly, I don't do very often), it always install itself in lib/VERSION, not in site_lib.

    If it didn't, you wouldn't be able to "seamlessly" upgrade CPAN (the CPAN shell always checks to see if there's a newer version available).

    So, I don't have an answer. I always assumed it would just work (and it always has for me).

Re: Upgrading Core Modules Using CPAN - Best Practice?
by almut (Canon) on Oct 02, 2008 at 22:51 UTC
    This means that putting Makefile.PL args in CPAN::Config may work for some modules but not for others.

    Could you point out an example module that doesn't allow to configure its install destination?  I mean, if this is true, how would CPAN.pm then achieve to install the module in the 'site' subtree, as you're saying? (just wondering)

      In the cpan shell, type the following command with the specific path where you need to update the core modules cpan> o conf makepl_arg PREFIX='<dir path>' cpan> o conf commit Default lib path will be changed after this command.. Lemme know if it works

        Getting the modules into the PREFIX path is not the problem. It is ensuring that the modules is installed in the correction location w/in the PREFIX path that is the problem:

        PREFIX=/usr/local/perl5.8.6
        /usr/local/perl5.8.6/lib/5.8.6/sun4-solaris/Errno.pm (core) /usr/local/perl5.8.6/lib/site_perl/5.8.6/Errno.pm (cpan)

      First off, thanks for all the feedback so far. 'Errno' is an example of one such module. This modules was installed as a core module to: /usr/local/perl5.8.6/lib/5.8.6/sun4-solaris/Errno.pm

      When I use CPAN to install this module, it defaults to installing in: /usr/local/perl5.8.6/lib/site_perl/5.8.6/Errno.pm

      I tried to specify the following arguments that would be passed to Makefile.PL to adjust the install path: 'makepl_arg' => qq[INSTALLDIRS=perl}

      With this makepl_arg set, the module still installs into the same directory.

      I did run across a post that suggested specifying the INSTALLPRIVLIB to the value of $Config{archlibexp} (while 'use'-ing Config), which does seem to tell the module to install into the correct location.

      So, if specifying the INSTALLPRIVLIB makepl_arg is a possible solution, the questions that remain are:

      • Do all core modules specify INSTALLDIRS=perl as their default location? If not, we would have to add this to CPAN::Config which may cause issues for non-core modules.
      • If I specify INSTALLPRIVLIB=$Config{archlibexp} in CPAN::Config, could this cause problems for some modules?

      Lastly, getting back to the original question, regardless of how it is done, is clobbering the old (core) version with the new (cpan) version of the module the recommended solution? Or would anyone suggest the @INC overlays?

Re: Upgrading Core Modules Using CPAN - Best Practice?
by mattk (Pilgrim) on Oct 03, 2008 at 08:19 UTC
    You can configure the CPAN shell to uninstall outdated modules like so:
    cpan> o conf mbuild_install_arg UNINST=1
    cpan> o conf make_install_arg '--uninst 1'
    
    Or follow the prompts:
    cpan> o conf init
    

      You appear to have them the wrong way around, it should be:

      cpan> o conf mbuild_install_arg '--uninst 1' cpan> o conf make_install_arg UNINST=1

      Similar settings in CPANPLUS are:

      CPAN Terminal> s conf buildflags uninst=1 CPAN Terminal> s conf makeflags UNINST=1 CPAN Terminal> s save

        This does appear to be a third possible solution, but the CPAN perldoc makes me a little weary about it. Specifically: In fine tuned environments UNINST=1 can cause damage.

        1) I installed a new version of module X but CPAN keeps saying, I hav +e the old version installed Most probably you do have the old version installed. This can happ +en if a module installs itself into a different directory in the @INC + path than it was previously installed. This is not really a CPAN.pm +problem, you would have the same problem when installing the module m +anually. The easiest way to prevent this behaviour is to add the argu +ment UNINST=1 to the make install call, and that is why many people a +dd this argument permanently by configuring o conf make_install_arg UNINST=1 2) So why is UNINST=1 not the default? Because there are people who have their precise expectations about + who may install where in the @INC path and who uses which @INC array +. In fine tuned environments UNINST=1 can cause damage.
Re: Upgrading Core Modules Using CPAN - Best Practice?
by Anonymous Monk on Oct 03, 2008 at 06:12 UTC
    http://search.cpan.org/dist/ExtUtils-MakeMaker/
    http://search.cpan.org/src/MSCHWERN/ExtUtils-MakeMaker-6.46/Makefile.PL
    INSTALLDIRS     => 'perl', make install

    make alone puts all relevant files into directories that are named by the macros INST_LIB, INST_ARCHLIB, INST_SCRIPT, INST_MAN1DIR and INST_MAN3DIR. All these default to something below ./blib if you are not building below the perl source directory. If you are building below the perl source, INST_LIB and INST_ARCHLIB default to ../../lib, and INST_SCRIPT is not defined.

    The install target of the generated Makefile copies the files found below each of the INST_* directories to their INSTALL* counterparts. Which counterparts are chosen depends on the setting of INSTALLDIRS according to the following table:

    INSTALLDIRS set to perl site vendor PERLPREFIX SITEPREFIX VENDORPREFIX INST_ARCHLIB INSTALLARCHLIB INSTALLSITEARCH INSTALLVENDORARCH INST_LIB INSTALLPRIVLIB INSTALLSITELIB INSTALLVENDORLIB INST_BIN INSTALLBIN INSTALLSITEBIN INSTALLVENDORBIN INST_SCRIPT INSTALLSCRIPT INSTALLSITESCRIPT INSTALLVENDORSCRIPT INST_MAN1DIR INSTALLMAN1DIR INSTALLSITEMAN1DIR INSTALLVENDORMAN1DI +R INST_MAN3DIR INSTALLMAN3DIR INSTALLSITEMAN3DIR INSTALLVENDORMAN3DI +R
    INSTALLDIRS
      Determines which of the sets of installation directories to choose: perl, site or vendor. Defaults to site.

      Won't putting INSTALLDIRS=>'perl' in CPAN::Config force all modules into the "core" path, even those that are not core modules?

        Whats your point?
Re: Upgrading Core Modules Using CPAN - Best Practice?
by Anonymous Monk on Oct 03, 2008 at 06:15 UTC
    Does anyone know of any best practices in regards to this?
    You really needn't worry, all CORE modules available as separate downloads on CPAN already know how to get installed in lib instead of site/lib :)
      You really needn't worry, all CORE modules available as separate downloads on CPAN already know how to get installed in lib instead of site/lib :)

      That is what I thought too, but then why did I end up with two versions of some modules installed when upgrading from CPAN?

      /usr/local/perl5.8.6/lib/5.8.6/sun4-solaris/Errno.pm (core: 1.09_00) /usr/local/perl5.8.6/lib/site_perl/5.8.6/Errno.pm (cpan: 1.10)
        Congratulations, you've found a bug, report it to whomever put Errno on cpan :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://715096]
Approved by DrWhy
Front-paged by MidLifeXis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found