Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Customary Perl setup on Apple Mac OS X?

by Anonymous Monk
on Aug 05, 2008 at 04:06 UTC ( [id://702211]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

What's the recommended Perl setup on Apple Mac OS X? (I'm currently using OS X 10.5.) I'd like to be able to use cpanp (or, failing that, cpan) to install modules.

If I build and install my own Perl from source, is it fairly straightforward? (That is, similar to how it builds and installs on GNU/Linux?) Any gotchas I should know about? I'll probably just put it into its own /opt/perl.

Incidentally, I've got Fink installed, and I notice that my @INC looks like this:

@INC contains: /sw/lib/perl5 /sw/lib/perl5/darwin /System/Library/Perl/5.8.8/darwin-thread-multi-2level /System/Library/Perl/5.8.8 /Library/Perl/5.8.8/darwin-thread-multi-2level /Library/Perl/5.8.8 /Library/Perl /Network/Library/Perl/5.8.8/darwin-thread-multi-2level /Network/Library/Perl/5.8.8 /Network/Library/Perl /System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.8 /Library/Perl/5.8.6 /Library/Perl/5.8.1 .

but there's no /sw/bin/perl.

So, it seems that the system Perl actually looks in the Fink /sw directory for modules to load -- thus, I can install Perl modules via the Fink apt-get and the system Perl will find them ...

Replies are listed 'Best First'.
Re: Customary Perl setup on Apple Mac OS X?
by wrinkles (Pilgrim) on Aug 05, 2008 at 05:52 UTC
    It's easy to install custom perl and modules, however I've historically had trouble keeping the various configuration settings straight to avoid conflicts. I've never had good luck mixing Fink and/or MacPorts with a cpan installation. I prefer installing cpan to my "/opt" directory and building non-CPAN perl manually with:
    ./Build install --install_base /opt/local/
    my bashrc contains:
    export PERL5LIB="/opt/local/lib/perl5:/opt/local/lib/perl5/site_perl:/ +opt/local/lib/perl5/darwin-thread-multi-2level:/opt/local/lib/perl5/a +uto"
    FWIW here's my MyConfig.pm I know have too many --install_base arguments, as I get an error message while installing from cpan (although it still installs). Not sure which ones need to go. Critiques welcome
Re: Customary Perl setup on Apple Mac OS X?
by EvanK (Chaplain) on Aug 05, 2008 at 04:46 UTC
    Honestly, I've never had much trouble with the Perl build that comes with the OS, other than it not being 5.10 (it's actually 5.8, if I'm not mistaken).

    That said, recompiling it is very straightforward assuming you have the developer tools installed (xcode, etc), since that contains all the make tools and c compilers. It should be the same process as building perl on *nix:

    ./Configure make make test make install

    __________
    Systems development is like banging your head against a wall...
    It's usually very painful, but if you're persistent, you'll get through it.

      Yes, I've got the Apple dev tools installed. Thanks.

Re: Customary Perl setup on Apple Mac OS X?
by Your Mother (Archbishop) on Aug 05, 2008 at 05:20 UTC

    I think Fink is... not so hot. I had more problems with it than I ever did learning to compile stuff from source. Fink came about, IIRC, during the Public Beta, when installing stuff yourself was for sysadmins and masochists (I spent two miserable weeks getting modperl/apache running on the PB). OS X is not like that anymore so Fink is just another level of code management to the things you want; you might have to wait a long time for a version bump you want. Even for special stuff like image libs, there are good instructions to be found via Google.

    Don't forget you have to install all the dev tools; last I checked they weren't in by default. They are one one of the system disks, probably, and can be downloaded from Apple if not. That gives you gcc and other goodies. Then it's just a matter of running cpan from the shell and switching to cpanp from there if you prefer. I recommend not running your box as root so you'll have to sudo cpan to install stuff and sudo make install if you're doing stuff outside the CPAN shell. It's a couple extra steps but it makes it much less likely you'll hose your installation, or worse.

      OS X is not like that anymore so Fink is just another level of code management to the things you want

      So, when building your own software, where do you install to? That is to say, what do you use for your "--prefix" when you "./configure" it?

      Then it's just a matter of running cpan from the shell and switching to cpanp from there if you prefer.

      Into which directory will modules be installed using that method?

        The great thing is I don't know the answer and I don't have to care. It just works. I have 5.10 on this thing. I left the default install in place and just made /usr/bin/perl point to my new perl. The perl installation walks you through that question/setting.

        moo@cow[50]~>sl /usr/bin/perl lrwxr-xr-x 1 root wheel 25 Mar 23 10:53 /usr/bin/perl@ -> /usr/loc +al/bin/perl5.10.0

        I can check various critters with perldoc -l but I've never once had to set up anything special for paths except the symlink for the new perl. That's the joy of root. If you don't do it as root, there are some great posts here about local CPAN installs. Here are a couple of examples of locations on this box but I had no idea where they'd be before checking-

        moo@cow[51]~>pd -l Storable /usr/local/lib/perl5/5.10.0/darwin-2level/Storable.pm moo@cow[52]~>pd -l Catalyst /usr/local/lib/perl5/site_perl/5.10.0/Catalyst.pm
Re: Customary Perl setup on Apple Mac OS X?
by pjotrik (Friar) on Aug 05, 2008 at 07:44 UTC
    When dealing with OS X, I was advised by experienced Mac users to install perl (and unix stuff in general) from the MacPorts (http://www.macports.org/). It went all very well, I only encountered a few gotchas resulting from perl not being located in its default destination:
    • You have to change the shebang in perl scripts, the trick is to use #!/usr/bin/env perl
    • You have to specify PATH in your crontabs

      Wow. Just as an aside here, the MacPorts website has come a long way since the last time I saw it. Very informative now. Nice work there!

Re: Customary Perl setup on Apple Mac OS X?
by dragonchild (Archbishop) on Aug 05, 2008 at 17:41 UTC
    What I've done is:
    • create a new volume that's formatted as case-sensitive HFS+
    • using Perl::Install, I have my own perl install outside of any root influence
    • put /Volumes/dev/perl/current/bin/ first in my path

    This solves a multitude of issues that case-insensitive filesystems have and I don't mess with system perl.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found