perl-begin / src / topics / cpan / life-with-cpan / macosx / index.html

Full commit
<?xml version="1.0" encoding='utf-8' ?>
    html public "-//w3c//dtd xhtml 1.1//en"
<html xml:lang="en-US">
<title> CPAN on Mac OS X</title>
<meta name="keywords" content=", unix, openssl, ssh"/>
<meta name="msvalidate.01" content="4D4AA5634CCCC8B90DD61AC8A12D742B" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="generator" content="XML::ApplyXSLT, libxml, and Perl"/>
<link rel="stylesheet" type="text/css" href="../default.css"/><meta name="MSSmartTagsPreventParsing" content="TRUE"/>


    <div class="header"><h1>CPAN on Mac OS X</h1></div>

    <div class='mainBody'>
      <div class="subsection"><a href="#s2">Upgrade System Perl?</a> | <a href="#s3">Case Folding Filesystem</a> | <a href="#s4">Panther (10.3) and <tt class="file">/man</tt></a></div><div class="bodymain"><p class="info">The <a href="">Comprehensive Perl Archive Network (CPAN)</a> is a collection of <a href="">Perl</a> modules and scripts distributed among a large number of mirror sites.  <a href="" title="Documentation on the CPAN Perl module"><tt class="perl-module">CPAN</tt></a> is also the name of a <tt class="cmd">perl</tt> module which provides an interface to install modules from <acronym title="Comprehensive Perl Archive Network">CPAN</acronym>. These notes document problems with <a href="" title="Documentation on the CPAN Perl module"><tt class="perl-module">CPAN</tt></a> on <a href="">Mac OS X</a>. See also the main <a href="../index.html">Life with <acronym title="Comprehensive Perl Archive Network">CPAN</acronym></a> documentation.</p><p class="info">Xcode (via <a href="">Developer Tools</a> must be installed (installing Xcode also installs the <a href="">Perl documentation</a> on Mac OS X). Another option is to run another Unix, such as <a href="">Debian</a>, under a <a href="">virtual machine</a>, and install whatever modules are required for development into the sandbox system.</p><h2><a name="s2">Upgrade System Perl?</a></h2><p class="info">I advise against upgrading the system <tt class="cmd">perl</tt>, and against installing Perl modules into the system <tt class="code">@INC</tt> directories. If a different version of <tt class="cmd">perl</tt> is required, install it from <a href="">MacPorts</a> (<a href="" title="Documentation on the App::perlbrew Perl module"><tt class="perl-module">App::perlbrew</tt></a> is another option, though does not support the installation of C libraries like MacPorts does). Changing the system <tt class="cmd">perl</tt> may break any scripts that rely on a particular version of software installed; Apple updates could also break the <tt class="cmd">perl</tt> or new modules improperly installed into the system area. Keep the vendor space separate from any local or site changes where possible. Administrative access is not necessary to install modules, as these can be <a href="../non-root/index.html">installed into local directories</a> via <a href="" title="Documentation on the local::lib Perl module"><tt class="perl-module">local::lib</tt></a>. An administrator would need to install Xcode, if that is not available. <a href="">Perl Software Depots</a> goes into more detail on the management of software installs.</p><p class="info">As of Mac OS X 10.6, the OS ships with multiple versions of <tt class="cmd">perl</tt> installed. Peruse the <a href="" title="FreeBSD man page search for perl, section 1"><tt xmlns:xlink="" class="man">perl(1)</tt></a> manual page on Mac OS X for more details on how to switch between the two, if necessary.</p><p class="data-shell">$ <kbd>sw_vers</kbd><br/>ProductName:	Mac OS X<br/>ProductVersion:	10.6.3<br/>BuildVersion:	10D573<br/>$ <kbd>perl -e 'system "ls $_/perl5*" for split /:/, $ENV{PATH}' 2&gt;/dev/null</kbd><br/>/usr/bin/perl5.10.0	/usr/bin/perl5.8.9</p><p class="info">If a custom version of Perl is installed, either the <tt class="code">PATH</tt> environment variable must list that <tt class="cmd">perl</tt> first, or the shebang line must be updated to always use the custom <tt class="cmd">perl</tt>. I strongly advise against using symlinks to overwrite vendor versions of <tt class="cmd">perl</tt>, as this again could cause unexpected problems should Apple release a patch that changes something; also, <tt class="cmd">perl</tt> is just one of many commands associated with Perl, so a symlink of just <tt class="file">/opt/local/bin/perl</tt> to <tt class="file">/usr/bin/perl</tt> will still cause <tt class="file">/usr/bin/cpan</tt> to be used, resulting in modules installed for who knows what Perl.</p><p class="data-shell">$ <kbd>which perl</kbd><br/>/opt/local/bin/perl<br/>$ <kbd>type -a perl</kbd><br/>perl is /opt/local/bin/perl<br/>perl is /usr/bin/perl<br/>$ <kbd>head -1 ~/bin/xmltidy</kbd><br/>#!/opt/local/bin/perl</p><p class="info">Consult the documentation for the shell used on how to configure the <tt class="code">PATH</tt> environment variable. Note that the <tt class="code">PATH</tt> and other environment variables may need to be set in the <tt class="file">environment.plist</tt> file for non-terminal programs such as <tt class="gui">BBEdit</tt>.</p><h2><a name="s3">Case Folding Filesystem</a></h2><p class="info">The default filesystem on Mac OS X (HFS+) folds case, unlike traditional Unix filesystems. Unix software that assumes <tt class="file">HEAD</tt> and <tt class="file">head</tt> are two different things on Mac OS X will end badly. For example, the <a href="" title="Documentation on the LWP::UserAgent Perl module"><tt class="perl-module">LWP::UserAgent</tt></a> module installs <tt class="file">/usr/bin/HEAD</tt>, which clobbers the existing <tt class="file">/usr/bin/head</tt> utility.  Solutions to this include not installing the <tt class="cmd">HEAD</tt> and similar shortcuts, or ensuring these utilities are installed under <tt class="file">/usr/local/bin</tt> instead.  One way is to update the <tt class="code">perl Makefile.PL</tt> arguments to install third-party utilities into a different directory than <tt class="file">/usr/bin</tt>.</p><p class="data-shell">cpan&gt; <kbd>o conf makepl_arg "INSTALLBIN=/usr/local/bin INSTALLSCRIPT=/usr/local/bin"</kbd><br/>cpan&gt; <kbd>o conf commit</kbd></p><p class="info">Due to the rise in popularity of Mac OS X, most of these issues have been worked around in popular modules, such as <a href="" title="Documentation on the LWP::UserAgent Perl module"><tt class="perl-module">LWP::UserAgent</tt></a>. However, older, or less frequently used modules may still contain code that assumes filesystem case sensitivity.</p><h2><a name="s4">Panther (10.3) and <tt class="file">/man</tt></a></h2><p class="info">Perl 5.8.1 on Mac OS X 10.3 shipped with broken settings that cause some modules installed from <acronym title="Comprehensive Perl Archive Network">CPAN</acronym> to install their manuals under the <tt class="file">/man</tt> directory.  This directory pollutes the root namespace, and is outside the places manuals are searched for by <a href="" title="FreeBSD man page search for man, section 1"><tt xmlns:xlink="" class="man">man(1)</tt></a>.</p><p class="info">To fix this problem, update the <tt class="code">makepl_arg</tt> to set <tt class="code">INSTALLSITEMAN1DIR</tt> and <tt class="code">INSTALLSITEMAN3DIR</tt> manually.</p><p class="data-shell">$ <kbd>grep makepl_arg /System/Library/Perl/5.8.1/CPAN/</kbd><br/>  'makepl_arg' =&gt; q[INSTALLSITEMAN1DIR=/usr/share/man/man1 <span class="rbr">?</span><br/>INSTALLSITEMAN3DIR=/usr/share/man/man3],</p></div>

		<div class="footer"><a href="../index.html"><img style="border: 0; float: right; margin-top: 1em; margin-right: 1em; margin-bottom: 5em" src="" width="64" height="64" alt="NovoSial Icon"/></a>
<p>This document is released into the public domain. Version 1.3.</p></div>