How should I install more than one version of Perl?
Asked Answered
B

6

18

I want to install, from source, Perl versions 5.005, v5.6, v5.8, v5.10

Right now I have 'v5.10.0' installed.

/opt/perl/bin
/opt/perl/html
/opt/perl/lib
/opt/perl/man
/opt/perl/lib/5.10.0
/opt/perl/lib/site_perl
/opt/perl/lib/site_perl/5.10.0

Will I have any problems if I install them all in /opt/perl?

Or should I split them up into their own, version specific, directories? Like /opt/perl-5.10.0/

Bayly answered 17/8, 2009 at 18:22 Comment(2)
You should also take a look at this: #398721Entomo
these days the easiest way to deal with multiple versions of perl is probably perlbrew metacpan.org/module/perlbrewSophi
C
15

I install all of my perls completely in their own directory so they don't share anything with any other perl. To do that, you just tell the Configure script where to install everything. I like /usr/local/perls:

 % ./Configure -des -Dprefix=/usr/local/perls/perl-5.x.y

When I do that for multiple versions, I get a directory that has separate installations.

% ls -1 /usr/local/perls
perl-5.10.0
perl-5.10.1
perl-5.6.2
perl-5.8.8

They all have their own bin and lib directories:

% ls -1 /usr/local/perls/perl-5.10.0
bin
lib
man

Most of the common tools will figure out what to do if you call them with different perls:

/usr/local/perls/perl-5.10.0/bin/perl /usr/local/bin/cpan

However, you can take the perl you want to use the most and put it first in your path. I just make a symlink to /usr/local/bin/perl, but you can add directories to PATH as well.

The perlbrew does a lot of this for you and moves symlinks around to make one of them the default perl. I don't use it though because it doesn't make life easier for me. That's up to you decide on your own though.

Cookson answered 18/8, 2009 at 0:52 Comment(8)
/usr/local/perls/bin could be a good place to put symlinks to the version specific Perls. Then I would only need to add that to PATH.Bayly
-1 :: It would be more helpful to also mention how to use cpan with multiple installation of Perl.Mcrae
Just call the cpan script in the appropriate bin directory just like you'd call the different perl programs.Cookson
This is how I have been managing this. Except using /opt/perl-5.16.0. With alias of /opt/perl/bin/perl-5.16.0 to /opt/perl-5.16.0/bin/perl, along with other aliases.Bayly
is this answer still correct? With 5.28 I get /usr/local/bin is not writable by you (using a prefix which is writable by me and totally outside of /usr/local/bin)Bugg
@OhMyGoodness it's still correct, but you need to have write permission to wherever you want to install it. That's always been true. I use a 'perl' group, add myself to that group, and make those directories owned and writable by that 'perl' group.Cookson
@briandfoy I do have permission; I don't want to install to /usr/local/bin; ./Configure -des -Dprefix=/foo yields /usr/local/bin is not writable by you when make install is invoked.Bugg
@OhMyGoodness perhaps you should ask a formal StackOverflow question.Cookson
A
7

Split them into their own version specific directories, and then symlink perl to the version you wish to use at the time. This is how having multiple JREs/JDKs installed works, so it would seem to make sense for Perl installations as well.

Arsenal answered 17/8, 2009 at 18:26 Comment(0)
D
2

You really should install the different versions into distinct directories.

When I want to try multiple versions of a package that doesn't exist as packages for my favorite Linux distribution, I use stow or xstow as a poor man's package manager:

  • Create a directory /usr/local/stow
  • Install individual packages into /usr/local/stow/$PACKAGE-$VERSION
  • map a "package" into /usr/local: stow -d /usr/local/stow $PACKAGE-$VERSION
  • deactivate a "package": stow -d /usr/local/stow -D $PACKAGE-$VERSION

stow does its work by creating and manipulating symlinks and it is able to detect conflicts.

Delivery answered 17/8, 2009 at 18:49 Comment(1)
More information on GNU Stow is available at the Stow home page. I am actively maintaining it.Piedadpiedmont
B
2

If you're using CentOS/RHEL servers, you can use the relatively new Software Collection system to install other versions of Perl in addition to the "system Perl" (which is an ancient 5.10 on EL6 and 5.8 on EL5).

There are public repositories for a core set of Perl 5.16 packages:

http://mirror.centos.org/centos/6/SCL/x86_64/

The community is working on publishing a larger subset of CPAN as installable packages and publishing collections for other versions of Perl as well.

Balderas answered 9/4, 2014 at 16:47 Comment(0)
D
0

We develop with multiple versions of Perl here at work, and separate directories is the way to go. We've set up a small shell command that fixes up symlinks and environment variables so you can use the perl you want easily.

If you're worried about forgetting which perl is being used, you could have such a script add a version number to your shell prompt.

Deltadeltaic answered 17/8, 2009 at 18:41 Comment(0)
A
0

While installing into different directories is usually a better way to go, you can use the Configure switch -Dversiononly to use a single directory and include the version triplet in all pathnames (except man files, which you'd probably want to avoid installing altogether), giving you for example a perl5.10.0, cpan5.10.0, perldoc5.10.0, etc.

Abomb answered 18/8, 2009 at 2:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.