0

I'm using perlbrew to run a local perl in my home directory, and cpan to install new modules. However, I seem to have something configured wrong. When I use cpan it always installs libraries to the ~/perl directory, but my perlbrew is located in ~/perl5 directory. This is causing some issue with creating appropriate PERL5LIB directory, rather I should include perl or perl5 libs and in what order. I seem to keep running into chicken and the egg problem where including either first results in loading a wrong module or complaints about the wrong version used. Specifically it complains that the 5.8.8 perl version (first I installed before deciding to upgrade to a slightly-less-ancient version, and still the version of /bin/perl) conflicts with the 10.1 libraries I'm using.

I figure this can likely be fixed by updating configuration files, but I'm not sure what to change. I look at my cpan config.pm and I don't see anything defining installation direction, in fact I'm not sure how cpan knows to install locally rather then trying to install to the global cpan directory.

Can anyone point me to the appropriate configuration values I need to change to get cpan to update my perlbrew library, rather then getting two separate libraries?

Edit

Okay I'm very blind. The answer was right in my configuration file at ~/.cpan/CPAN/MyConfig.pm. I swear I looked at the file a few times, even doing a search for the word perl to hunt down any line that may point to my ~/perl directory, and yet somehow missed the blindingly obvious configuration option I was looking for...not sure how.

Anyways, once I saw it I just had to change where it pointed, which took a little trial in error. I changed this line:

'makepl_arg' => q[PREFIX=~/perl],

to

'makepl_arg' => q[PREFIX=~/perl5/perlbrew/perls/perl-5.10.1/],

which of course is the location of the perl version I'm using for perlbrew. This appears to fix my problem, and should have been easy if I wasn't blind.

I do have one annoyance, I have both this line and my PERL5LIB variables, set in ~/.bashrc, effectively hard coded to point to the perl-5.10.1 version of perllib, meaning if I decide to switch to another perl version I would need to update both references or have issues again. I'm not sure how to make cpan, or my PERL5Lib for that matter, know to infer which version of perl from the perls directory it should use. That's not too big of a problem to me, I don't think I'll be allowed to upgrade past 5.10.1 (even though I want to) so it's unlikely I'll ever change this value. Otherwise it works fine now.

dsollen
  • 6,046
  • 6
  • 43
  • 84
  • 1
    What does `which cpan` output? – ThisSuitIsBlackNot Jan 08 '16 at 16:00
  • 1
    What's the output of `set | grep ^PERL`, and what's the output of `echo 'o conf' | cpan | grep 'make_\|mbuild_'`? – ikegami Jan 08 '16 at 16:08
  • @ThisSuitIsBlackNot the answer is ~/perl5/perlbrew/perls/perl-5.10.1/bin/cpan. However, I seem to have found a proper fix as mentioned in my edit. I'll likely live this open for a few hours just so those that started to answer can see that I found a fix, and/or complain if it's a stupid fix before either closing it or self answering if no one else answers. If you or ikegami wish to get credit for putting some effort into answering my question either is welcome to post an answer either repeating my fix or potentially pointing out any flaw in my fix and I'll select it to give you credit – dsollen Jan 08 '16 at 16:54
  • @ikegami nothing returns for the second. quite a few variables are set for the first, However, I seem to have found a proper fix as mentioned in my edit. As I said in my above comment, I'll self answer in a little while possible, but wanted to give you a chance to jump in with an answer to get credit first if you were interested :) – dsollen Jan 08 '16 at 16:58

1 Answers1

1

Two problems.

  1. Your CPAN is partially configured overriding the location at which it should install modules. Remove this override by clearing makepl_arg.

    From within cpan:

    o conf makepl_arg ""
    o conf commit
    

    From sh:

    echo -e -n 'o conf makepl_arg ""\no conf commit\n' | cpan
    
  2. Your PERL5LIB is telling your perl to look for modules where it shouldn't. Unset it by removing the instruction that sets it in ~/.bashrc.

You may have other problems, but we'd need to know the output of the following sh command to know for sure:

set | grep ^PERL ; echo 'o conf' | cpan | grep 'makepl_\|make_\|mbuild_'
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • you are right, it seems it was over configured. Not sure how that happened, but given the insanity I was going through with systems at the time I configured this I'm not too sure. I'm afraid I can't give the full content of the set command since the system I'm configuring isn't currently able to connect to internet (long story) so it's a little difficult to copy long messages over; but removing the changes do seem to work fine thank you. – dsollen Jan 08 '16 at 17:14
  • I'm particularly interested in `PERL_MM_OPT` (should probably be blank), `PERL_MB_OPT` (should probably be blank), `PERL5LIB` (already provided; should be blank), `PERLLIB` (likely blank; should be blank) and `PERL5OPT` (likely blank; should probably be blank). I'm specifically disinterested in any `PERLBREW_*` variables. – ikegami Jan 08 '16 at 17:20