Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Where do local Perl modules go?

Where do local Perl modules go?
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2002
Status: Offline
Reply With Quote
Sep 29, 2004, 09:25 AM
 
Hello.

Okay, I've got a few perl modules I need to install. I'm not big on CPAN (I prefer to run my own perl Makefile.PL, make, make test, make install).

I've read somewhere (although I can't find the webpage) that it is a good idea to install custom perl modules into /usr/local to avoid messing up MacOS X's default perl modules.

I'm trying to figure out how this should work.
Do I just create a directory in /usr/local/<perl module director>. Add it to the @INC path for perl?
If so, how do I tell future perl modules I want to use where to look for previously installed perl modules?
Finally, how do I uninstall a module that I don't want anymore?

Does this make any sense?
PowerBook G4 800Mhz
1GB RAM
60GB 7200rpm Hard Drive
Running Tiger
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Sep 29, 2004, 10:03 PM
 
When you first install CPAN using sudo perl -MCPAN -eshell you will be presented with the option of configuring your installation. You can specify where you want the modules. I've used /usr/local/perl and ~/perl. Currenly /usr/local/perl has my modules. The CPAN installation willl create directories where needed.

In the info presented when first installing, the command to re-configure is given. You can Google OS X CPAN to get lots of help.

Craig
     
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Sep 30, 2004, 01:29 PM
 
or if you insist on continuing to use the configure/make/install method, i think you can do something like this:
Code:
./configure --prefix=/usr/local
     
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Sep 30, 2004, 09:45 PM
 
Originally posted by GATTACA:

I've read somewhere (although I can't find the webpage) that it is a good idea to install custom perl modules into /usr/local to avoid messing up MacOS X's default perl modules.

I'm trying to figure out how this should work.
Do I just create a directory in /usr/local/<perl module director>. Add it to the @INC path for perl?
If so, how do I tell future perl modules I want to use where to look for previously installed perl modules?
I'm not sure, but I wonder whether you're slightly misunderstanding
the advice. If you install modules they'll go into a site-perl directory (relative to your current perl installation), and this won't be touched if Apple chooses to install a later Perl.

The /usr/local recommendation is probably for if you choose to install a new version of Perl yourself. This is pretty easy to do (5.8.5 compiles out of the box on Panther for example), and the default is for everything to live in /usr/local/. The perl binaries are thrown in /usr/local/bin, the modules are in /usr/local/lib/perl5/... and so forth.

In short, I'd just install the modules into the standard location and trust the directory structure to do the right thing with respect to possible upgrades.

Cheers,
Paul (happily running the 5.8.1 stock perl and 5.8.5 in /usr/local)
     
GATTACA  (op)
Fresh-Faced Recruit
Join Date: Jun 2002
Status: Offline
Reply With Quote
Oct 1, 2004, 01:52 PM
 
Thanks for all of your replies.

I'm liking this CPAN idea.
The only concern I have is what if I want to uninstall a CPAN module? Is this easy to do?
PowerBook G4 800Mhz
1GB RAM
60GB 7200rpm Hard Drive
Running Tiger
     
GATTACA  (op)
Fresh-Faced Recruit
Join Date: Jun 2002
Status: Offline
Reply With Quote
Oct 4, 2004, 09:21 PM
 
Tried the CPAN idea. Doesn't work.
It seems I need root access to install the modules. Since this particular powerbook isn't mine, I our tech support is a little uneasy about granting a user root access.

So back to square one I guess.
PowerBook G4 800Mhz
1GB RAM
60GB 7200rpm Hard Drive
Running Tiger
     
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Oct 5, 2004, 08:29 AM
 
you can configure cpan to install into any directory you want...for instance a ~/perl/lib directory. Edit the file:

Code:
~/.cpan/CPAN/MyConfig.pm
And modify/add the hash item makepl_arg with the following string:

Code:
q[ LIB=/Users/USERNAME/perl/lib INSTALLMAN1DIR=/Users/USERNAME/perl/man/man1 INSTALLMAN3DIR=/Users/USERNAME/perl/man/man3]
You will be able to then maintain your own little library of perl modules. Just make sure to add the lib directory to your path in your scripts that use one of the new modules:

Code:
use lib qw(/Users/USERNAME/perl/lib);
     
GATTACA  (op)
Fresh-Faced Recruit
Join Date: Jun 2002
Status: Offline
Reply With Quote
Oct 7, 2004, 06:44 PM
 
I finally solved my problems!

I convinced the IT people that installing perl 5.8.5 on the powerbook would in no way damage it (thanks to Paul McCann here).

So I downloaded the latest Perl source code and compiled it. and put it into my path. Now when I use CPAN, everything gets installed into my local ~/perl directory and it works! No hicups!


Thanks for your comments everyone!
PowerBook G4 800Mhz
1GB RAM
60GB 7200rpm Hard Drive
Running Tiger
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 04:47 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2