I installed Ubuntu earlier this weekend and had to install an updated version of perl(5.22.0) for a script I'm using. However when I used CPAN to install the modules I needed I found out that they got installed in Ubuntu's default perl(5.18.2). I've ran perl -l
and its showing the updated perl5, but for some reason CPAN refuses to use it.
I'm sure its a configuration issue or I'm misunderstanding how CPAN works. Either way i have looked through pages and pages of google trying to find a solution to no avail. I'm hoping someone here could guide me in the right direction and maybe this could be of some help to others having a similar issue.
Best Answer
I had exactly the same problem. Caveat: I'm using fedora. But, fc22 broke my perl scripts [the perl 5.20.3 interpreter would segfault], so I had to install 5.22.0, so I have some direct experience with this.
First, how you installed. I'm guessing that you used the installer to install the binary package for 5.22.0. Did this overwrite
/usr/bin/perl
? I assume so. Or, did it get installed as (e.g.)/usr/bin/perl-5.22.0
?In
/usr/lib64/perl/Config.pm
, look at the bottom to find the tied hash. This will have the configuration. Another [perhaps better] way to get this is to dump out@INC
and douse Config;
and dump out theConfig
hash from a [of course--perl] script.Of particular interest will be the
privlibexp
,sitearchexp
,sitelibexp
, andarchlibexp
variables.Dumping
@INC
is the most definitive.The question to note/answer is: Does the 5.22.0 perl interpreter use the 5.22.0 directories or does some of the config still point to 5.18.2?
Under one or more of these directories should be
CPAN.pm
along with theCPAN
subdir. My guess is that you'll find it only under the 5.18.2 related directory.In fact, with some investigation, you may find that you now have a "hybrid" installation that is neither quite 5.18.2 nor quite 5.22.0. If you [decide to] follow my "recommended best practice" [see below], you may wish to uninstall 5.22.0 so you have a stock/standard 5.18.2 installation. This minimizes headaches if Ubuntu does issues a patch.
When a distro installs perl packages that overlap with packages you can get from CPAN, it works, sort of. But, in reality, they often clash. Also, using a non-standard perl version against the distro requires even more care.
You'll probably have to install CPAN under the 5.22.0 directory using the new interpreter. That may be the short answer.
So, this brings up the question of how CPAN got installed in the first place. Did it come from the distro or did it get pulled and installed manually? If from distro, an "upgrade" may work. Otherwise, manually install it from the new perl interpreter--that should send it [and anything it installs] to the correct place.
Also, under
$HOME
you should find a.cpan
directory [if you've run it]. Of particular interest is$HOME/.cpan/CPAN
subdir. It should have a cpan config file (e.g.$HOME/.cpan/CPAN/MyConfig.pm
). There are a number of variables, butmake_install_make_command
may be of some use[Side note: I've been doing perl for 20+--my current script repo has 250,000 lines in it].
I've had to deal with this sort of problem a few [more than a few] times. Frankly, I don't "fight" the distro anymore, because of problems like the one you're having. Even though, on paper, distros claim to be able to install multiple package versions simultaneously, I've always had bad luck with this--perl in particular.
IMO, and in my experience, the problem you're having is just the tip of the iceberg. Even if you solve, there are probably more, similar problems later on.
If I need an alternate perl version, I go to the perl website, download the source tarball and rebuild it. Note: The recommended advice [from the perl website] is to download the source from the perl website and not try to rebuild from a distro source package.
I specify an alternate prefix to the
./Configure
script so that everything gets put in a new place. Then, do amake
andmake install
.For example, my 5.22.0 perl is under
/home/alt/perl/perl-5.22.0
and hasbin/perl
,lib/CPAN.pm
, andlib/CPAN
under it. I am able to maintain as many different versions as I want because they each to to/home/alt/perl/<version>
After that, I can do (e.g.):
ln -sf /home/alt/perl/perl-5.22.0/bin/perl /usr/bin/perl22
and change the scripts I want to use it with#!/usr/bin/perl22
.Here are the options I use to configure perl. The first three are the most important [*]:
Note that because I was having trouble with fedora's 5.20.3, I may have added some extra debug options that you won't need.
Another place to put this is
/home/myself/perl/perl-5.22.0
if you want a private/experimental copy.NOTE: Because I used a completely different place to install 5.22.0, 5.22.0 and 5.20.3 coexist in complete harmony. They do not interfere in any way [AFAICT].
You can even try this without interfering with the 5.22.0 you've already installed.
[*] P.S. Of course, I have a fully automated perl script to do all this configure, build, install [and pull tarball from website]
These will not be runnable as is, because they require/assume a lot of my existing infrastructure. They're merely for a loose reference. If you care to look at all, ignore about 99.44% of what you don't immediately recognize.
Here's the perl specific script:
Here's it's primary library [which is the basis to build other things, such as glibc, gcc, etc]: