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

perl's compiled-in @INC path searches directories named after the complete version number of the perl binary -- for example, /usr/lib/perl5/site_perl/5.8.0. Why is the full version number included? I thought multi-part version numbers were used so that you could promise API compatibility across the leading portion. But if that's the case, then why force modules to be installed under a particular patchlevel?

This is partly worked around by making newer minor versions of perl search through all of the older minor versions belonging to the same major version. But that still means that if you install a later version, then every module from that point on will install itself into that later version's directory. Which is a problem if you want to roll back the version of perl you're using.

Where I run into the problem is when I keep my development box more up to date than my production boxes. I build RPMs of modules that I want to release to the production boxes. But because I am running a later version of perl, those RPMs end up getting installed into directories that won't be searched on the production boxes. I am very tempted to recompile the perl that I run on production machines so that it will search eg /usr/lib/perl5/site_perl/5.8 or even /usr/lib/perl5/site_perl/5, and then figure out how to coerce MakeMaker to install things into those directories during my RPM build process. But it feels like I'd be fighting with something that's probably had a lot of thought put into it.

Anyone have advice or experience with this?

  • Comment on Version-independent installation directories

Replies are listed 'Best First'.
Re: Version-independent installation directories
by Zaxo (Archbishop) on Apr 13, 2005 at 08:07 UTC

    One common way to package for the version you want to distribute is to install your perls with version suffixes. You can set that up at Configure time. Then when you wish to package or install for the earlier version, just call the perl you want, for example, $ perl5.8.1 Makefile.PL

    After Compline,
    Zaxo

Re: Version-independent installation directories
by PodMaster (Abbot) on Apr 13, 2005 at 08:55 UTC
    That's just the default configuration. If you want it done different, edit the Config.pm. Its best to take care of this before compiling your perl (during Configure).

    For extra confusion ;) read about installstyle in Config, and about "PREFIX and LIB" in ExtUtils::MakeMaker.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Version-independent installation directories
by polettix (Vicar) on Apr 13, 2005 at 08:20 UTC
    Lazy as I am, I made a symbolic link from the 5.8.6 directory to the 5.8.0 directory during last upgrade; this should have less impact than recompiling and figure out how to coerce MakeMaker.

    Flavio (perl -e "print(scalar(reverse('ti.xittelop@oivalf')))")

    Don't fool yourself.
Re: Version-independent installation directories
by ysth (Canon) on Apr 13, 2005 at 08:12 UTC
    FWIW, the cygwin distribution's perl was recently changed to use just 5.8.
Re: Version-independent installation directories
by Tanktalus (Canon) on Apr 13, 2005 at 15:05 UTC

    I would highly, highly recommend not doing that. Running your development and production boxes on different levels, that is. What if, for example, you triggered a perl memory corruption that has been fixed (common problem here)? So, if you're using perl 5.8.6 in development, you never see the problem. As soon as you put it in production on 5.8.0, bam!, core dump. Now you're scrambling to recover since your production server isn't working anymore.

    Better to use the same level on both boxes, find the problem in development, and come up with a plan to get your software working in production. This can be a plan to upgrade the world to 5.8.1 or 5.8.6 or anything in between, or it can be a plan to try to not do whatever causes the memory corruption (e.g., don't use as many globs - I had that problem in 5.8.0, and this was my solution since 5.8.1 wasn't out yet). But it will be a plan, and one you can execute quickly with a reasonably well-known downtime for your production server. There will be fewer gotchas and surprises at the last minute - which is always a good thing. You can have all of management buy in to the plan. And they will be much happier with known issues than they will with unknowns that jump up and catch them. What if someone had a critical need for the production server you just took down 30 minutes after you took it down? By having a reasonable estimate of the affects of an upgrade, you can tell everyone that the server is going to be unavailable for that time period, and can negotiate a time for the upgrade that is appropriate, rather than surprising everyone with that crash.

    Yes, I'm rambling. It's that important.

      My machines really have four different roles: production, testing, build, and development. I think your first paragraph is arguing for the same version on testing and production, which I certainly agree with -- I also am very familiar with memory corruption bugs in various version of Perl. (Including some that haven't been fixed as of 5.8.5...) And my original question is irrelevant if I run the same version on my build box as on the production boxes.

      I certainly don't want to always run the same version on my development box as on the production box; I'd never be able to upgrade that way. But I don't think that's really what you're saying.

      So I think you're right, in that it shouldn't really be an issue. I ought to build the RPMs on both the build and development boxes, and install the build box's version on testing and production, and the development box's version on development. The problem is, I'm lazy and don't really have a distinction between development and build boxes most of the time. Not only that, but I can't tell from just the RPM filename what version of Perl it was built for. So I keep running into problems where I keep trying to install the wrong RPM on the wrong box. (Dependencies catch the problem, assuming I'm not being stupid and using --nodeps. Which I often am. But I still end up copying the wrong RPM to the "install all these on this box" directories.)

      Considering that most of these are pure-perl, noarch RPMs, it's annoying -- the bits are identical, but they go into different directories according to what are supposed to be versions of Perl with identical public APIs.

        Actually, I didn't realise you had four roles, and thus four (or more) machines. But, given that new piece of information, I would argue that keeping them all in sync is a good idea, too.

        This doesn't mean you can't upgrade. It means that you plan and schedule your upgrades. You plan an upgrade to your dev box. If your white-box testing fails to find problems, you then proceed with build/test upgrades. Once everything is tested satisfactorily, you proceed with the production upgrade. Everyone (all affected parties - mostly managers) has buy-in at each stage. If intractable problems are found (hopefully prior to production), you roll back to the previous level. Perhaps you get to that point, and decide to try a different level. But your production server isn't affected until you have something that works.

        And, yes, this makes the whole initial question pretty much moot. :-) That's kind of the point - to solve the problem in such a way that lots of problems are solved, rather than a band-aid for just part of the problem. Otherwise, you end up in a project of band-aids, rather than a robust, well-tuned machine. Remember - the point isn't to write code, but to produce revenue. And I presume that the production server is critical to that last part.

PERL search path
by darkphorm (Beadle) on Apr 13, 2005 at 16:01 UTC
    I've found on my boxes that the search path @INC also includes /usr/local/lib/site_perl, which is where I tend to put my customize perlmodules, etc.

    Perhaps this is just a Debian thing, but it seems to work for all the various perl versions between stable/unstable. If it's the same on your machine though, you could probably put your modules there regardless of Perl version.
      $ perl -V Summary of my perl5 (revision 5.0 version 8 subversion 3) configuratio +n: Platform: osname=linux, osvers=2.6.4, archname=i586-linux-thread-multi uname='linux g194 2.6.4 #1 smp fri jan 14 13:01:26 utc 2005 i686 i +686 i386 gnulinux ' <snip> Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL +_IMPLICIT_CONTEXT Built under linux Compiled at Feb 5 2005 12:25:37 %ENV: @INC: /usr/lib/perl5/5.8.3/i586-linux-thread-multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.3/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl $ cat /proc/version Linux version 2.6.4-52-default (geeko@buildhost) (gcc version 3.3.3 (S +uSE Linux)) #1 Wed Apr 7 02:08:30 UTC 2004