Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: 2nd Perl installation on Mac OSX

by trwww (Priest)
on Jun 26, 2009 at 00:41 UTC ( #774873=note: print w/replies, xml ) Need Help??

in reply to 2nd Perl installation on Mac OSX


I work on so many different projects that having them each have their own perl install has been very beneficial. It is really simple once you understand the workflow.

Consider the following directory structure:

/home/me/projects /home/me/projects/project1 /home/me/projects/project2

And designate that I want perl dedicated to each project. In each project directory, I have a ./src directory. In that directory, I have a perl source distribution extracted from a tarball downloaded from In that directory, I run:

sh Configure -de -Dprefix=/home/me/projects/project1/perl make make install

After the make install runs, there is a perl isolated from the rest of the system in the directory as specified in the configure command.

Next, I use a terminal dedicated for that project and set the environment variable PATH to look in the desired directory when I run perl at the terminal. I do this by making a script in the project's bin directory, and sourcing this script:

$ cat /home/me/projects/project1/bin/environment #!/bin/bash export PATH="/home/me/projects/project1/perl/bin:$PATH" $ chmod 775 /home/me/projects/project1/bin/environment

Then every time I open a new terminal for this project, I source this environment script:

$ which perl /usr/bin/perl $ . bin/environment $ which perl /home/me/projects/project1/perl/bin/perl

Now you have a perl isolated to the given project that will not interfere with the system perl at all.

There is one other thing that you need to keep in mind: The CPAN configuration for this install. By default, when you run perl -MCPAN -e shell or similar as a non root user, perl will want to put the cpan configuration in /home/me/.cpan. This is okay, but when you have more than one local install of perl (say, project1/perl and project2/perl), using /home/me/.cpan for both will conflict. To remedy this, make sure to use manual configuration when running the given perl's CPAN configuration for the first time, and choose a unique place to store the CPAN configuration directory. I use /home/me/projects/project1/perl/.cpan.

And now you have a completely isolated perl ready to use for your project that will never bungle up the system's perl. To uninstall this perl, you simply rm -rf /home/me/projects/project1/perl.

This concept works for applications in general, especially on linux based systems. For example, the popular chat application pidgin has started to have problems connecting to yahoo because of configuration changes at yahoo. The pidgin folks have this problem fixed in the most recent version, but the apt and yum repositories don't have the most recent versions yet. So to solve this problem, you can install a more recent version from source in a unique area using the prefix option to configure, and launch that pidgin. Then when the apt repo gets the fixed version, you can apt-get upgrade the system pidgin and rm -rf the locally installed one.

Hope this helps!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://774873]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2017-09-22 01:20 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (255 votes). Check out past polls.