Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Building a local perl to use the system perl's libraries as a fallback

by clueless newbie (Friar)
on Nov 30, 2012 at 13:27 UTC ( #1006475=perlquestion: print w/ replies, xml ) Need Help??
clueless newbie has asked for the wisdom of the Perl Monks concerning the following question:

Ave,

Assume I'm installing Ubuntu 12.10 which comes with perl 5.14.2. From the package manager I supposedly can install Devel::ptkdb and Padre. (Note: I tried previously to install both padre and Devel::ptkdb via CPAN unsuccessfully.) Since I don't want to break the system's perl I'll also use the package manager to install perlbrew.

Using perlbrew I want to install another copy of perl 5.14.2 (call it local perl) but I want it to use the system perl's libraries as a fallback so its @INC would look like

(<local perl @INC>, <system perl @INC>)

so that local perl can make use of system perl Tk, PPI etc.

Googling suggests that I can use perlbrew's --sitecustomize switch to do this.

Does this seem reasonable? Comments and suggestions welcome!

Comment on Building a local perl to use the system perl's libraries as a fallback
Download Code
Re: Building a local perl to use the system perl's libraries as a fallback
by tobyink (Abbot) on Nov 30, 2012 at 13:29 UTC

    "Assume I'm installing Ubuntu 12.10 which comes with perl 5.14.2."

    No idea. But your use of the word "assume" intrigues me. :-)

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Building a local perl to use the system perl's libraries as a fallback
by moritz (Cardinal) on Nov 30, 2012 at 15:24 UTC
    Does this seem reasonable?

    No. It seems very dangerous to me.

    XS modules can be binary incompatible between two perls that were compiled with different flags. For example the perl that comes with Ubuntu is compiled with -Dusethreads, and so XS modules compiled for that perl will assume that perl is threaded. Now if the perlbrew-installed perl wasn't configured with threads, and tries to load a threaded XS module, things could go very badly.

    In the best case you'll get a segmentation fault pretty quickly. In the first case you'll simply get memory corruption and thus output values that are wrong in subtle ways, and you will have a very hard time finding and diagnosing those errors.

    And there are many more flags than just threading, so much potential for things to go wrong.

    So, don't make such a fallback. Instead simply install missing modules for the perlbrew installation when needed. Run

    perlbrew install-cpanm

    and then your modules are just a cpanm Desired::Module away.

Re: Building a local perl to use the system perl's libraries as a fallback
by zwon (Monsignor) on Nov 30, 2012 at 15:33 UTC

    Can you explain what are you trying to achieve? You can add path to system libraries to @INC, and your local perl will search for modules there, but if you use different compilation options for local perl it may not be compatible with system libraries, and if you use the same options, then why don't just use system perl?

      On a fresh install of Ubuntu 12.10, I have NOT been able to install padre or Devel::ptkdb successfully from CPAN. But if I use Ubuntu's apt-get both install and work without any problems. Since "mucking" about with the system perl is considered "not the thing to do", I want to create a user perl that takes advantage of the successfully installed modules of the system perl.

      Moritz brings up an excellent point and I would be careful to configure the local perl with the options of the system perl.

      As I understand it, modules installed from CPAN via the local perl would not pollute the libraries of the system perl.

        You may have to install headers of the libraries XS code uses (i.e. simply speaking, files in /usr/include/ which point to the functions defined in *.so files). For example, building Wx from CPAN requires libwxgtk2.8-dev to be installed.
        Sorry if my advice was wrong.
        If you just want to be able to install modules into your home directory without touching the system libraries, you probably should have a look at local::lib. I don't use it myself, but I recall that system cpan command suggested to configure it automatically during first run on Ubuntu.
Re: Building a local perl to use the system perl's libraries as a fallback
by Anonymous Monk on Nov 30, 2012 at 20:31 UTC
    Look for threads on "installing Perl as a non-root user." You can set up your own personalized copy of Perl and you probably want to do so if Perl is used as part of the package-management software (or other key software) on your Linux distro. Use packages (only...) to maintain whatever the other parts of your system depend on. Use the "non-root user" techniques to maintain, separately, your own custom environments. Keep the two entirely separate.

      This is exactly what I'm trying to do ...

      Only I want to piggyback off of the work of the distro whose Devel::ptkdb and Padre already work.

Re: Building a local perl to use the system perl's libraries as a fallback
by clueless newbie (Friar) on Dec 02, 2012 at 16:22 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1006475]
Approved by tobyink
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2014-09-16 06:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (157 votes), past polls