Skip to content

Instantly share code, notes, and snippets.

@jkeenan
Created June 7, 2015 22:35
Show Gist options
  • Save jkeenan/37fbe0432816ed1f4189 to your computer and use it in GitHub Desktop.
Save jkeenan/37fbe0432816ed1f4189 to your computer and use it in GitHub Desktop.
Request help on interaction between 'perlbrew' and 'cpanm'

Perl 5.22 just came out. Up until last year, when a new perl would come out, I would download a tarball to my machine (either an older Mac laptop or a Debian server on http://linode.com), unpack the tarball, configure, build and test from source, and finally call sudo make install to install the executable into /usr/local/bin. I would then use the cpan shell to download, configure, build and install Perl modules into /usr/local/lib.

In other words, I would install Perl and its libraries in a traditional Unix-y way.

When I got my current laptop in March 2014, I decided to take a different approach. I decided to forego installing into /usr/local and to instead use perlbrew to install all the perl versions I wanted underneath my home directory. One reason I took this approach is that in the work I do for Perl 5 Porters, it's important to be able to switch back and forth between various Perl versions with great ease.

I also decided to start using cpanm to install Perl modules, so Perl libraries are now going underneath my homedir. In other words, I'm no longer using /usr/local/ very much to manage my Perl.

Now, I'm a little hazy as to whether I'm also using local-lib or not, or how I'm using it if indeed I am. But just hold your tongue on that for a minute, s.v.p.

In any case, my Perl libraries are now all getting installed here: /home/jkeenan/perl5/lib/perl5/. Example:

$ perldoc -l List::Compare
/home/jkeenan/perl5/lib/perl5/List/Compare.pm

I was quite content with this arrangement until this past week. As I noted, Perl 5.22 came out this last week. I used 'perlbrew install' to install it underneath my homedir just like 5.18.4, 5.20.1, etc. Then I remembered that I'd now have to recompile and reinstall modules like Devel::Cover and DateTime that have XS code, since that code has to be compiled against a specific version of Perl. One such module is Term::ReadKey, which I use in a little program.

$ littleprogramusingtermreadkey.pl
perl: symbol lookup error: /home/jkeenan/perl5/lib/perl5/x86_64-linux/auto/Term/ReadKey/ReadKey.so: undefined symbol:    Perl_xs_apiversion_bootcheck

So then I tried to use 'cpanm' to update Term::ReadKey:

$ cpanm Term::ReadKey
Constants from lexical variables potentially modified elsewhere are deprecated at /loader/0x11061b8/aliased.pm line 1.
 
--> Working on Term::ReadKey
Fetching http://www.cpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.33.tar.gz ... OK
Configuring TermReadKey-2.33 ... OK
Building and testing TermReadKey-2.33 ... OK
Successfully installed TermReadKey-2.33 (upgraded from 2.32)

So far so good. But I now realize that I just compiled Term::ReadKey against perl-5.22.0, but installed it in the same directory tree where for the past year I've been compiling modules against perl-5.20.1 for the past year.

$ perldoc -l Term::ReadKey
/home/jkeenan/perl5/lib/perl5/x86_64-linux/Term/ReadKey.pm

So now /home/jkeenan/perl5/lib/perl5/ is holding both perl-5.20 libraries and perl-5.22 libraries.

Somehow, I do not think this is a Good Thing.

I realize what I ought to be doing is compiling updated versions of modules with XS against specific Perl versions and installing them with respect to specific Perl versions built by perlbrew. That way, when I say perlbrew switch perl-5.22 I will, going forward, be working in a Perl 5.22 universe.

What is the most expeditious way of doing this?

Thank you very much.

Jim Keenan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment