I don't know what happened since the last post, but I was no longer able to install CPAN modules on my MacBook Pro running Mac OS X Snow Leopard. CPAN didn't like that YAML was not installed, and I wanted to upgrade my Perl installation from 5.12 to 5.14. Finally, I figured all this out. Here is what I did:
1. Install Perl 5.14. Instructions are here. I downloaded the package from http://www.activestate.com/activeperl/downloads, opened the installer and installed the package. This part is easy and straightforward.
After this step, however, my Mac was still using Perl 5.12 rather than the new version. You can check which version your Mac is using by opening a terminal and typing:
perl -v
So you need to add the path to the new Perl version to your path.
2. Instructions for adding the path to the new Perl version to your path your Mac is here. More instructions on how to edit the path file (".profile" file in your user home directory) are available at http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/ and http://www.tech-recipes.com/rx/2618/os_x_easily_edit_hidden_configuration_files_with_textedit/. Doing this tells your Mac where to look for Perl when you type the perl command at the command prompt.
Your .profile file will be located in the "user home directory." For me, this is /Users/shafique. For you it will be whatever /Users/. To check what is in your PATH environment variable, in the terminal window type:
env
or
echo $PATH
Now to add the new path to my path variable, I edited the .profile file using a text editor:
open ~/.profile
Go to the Text Editor, and add the following lines at the end of the text file that the editor just opened:
Yes, you will type out all three dots on this line. This adds the new Perl path to your environment PATH variable. Now you should be all set. To check which Perl version you are now running, type:
perl -v
and it should show that you are running version 5.14. If not, check your PATH variable:
env
or
echo $PATH
If it doesn't show that the new Perl version directory has been added to your PATH variable, then... well I don't know what to do.
3. Go ahead an install YAML. In your terminal window, type:
sudo perl -MCPAN -e 'install +YAML'
and then enter your password when the terminal asks for it.
4. Go ahead and upgrade CPAN. In your terminal window, type:
sudo perl -MCPAN -e 'install CPAN'
5. Uninstall previous versions of Perl:
6. Remove all symbolic links to previous version of perl in the directories listed in your $PATH variable and replace them with symbolic links to the new versions. Start by finding out which paths may have outdated links:
echo $PATH
Here is what I had to do:
sudo rm /opt/local/bin/perl
sudo rm /opt/local/bin/perl
sudo rm /opt/local/bin/perl5
sudo rm /opt/local/bin/perl5.12
sudo rm /opt/local/bin/perl5.12.4
sudo rm /user/bin/perl
sudo rm /usr/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /usr/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /opt/local/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /opt/local/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /usr/local/perl
If you don't do this, then your editor (I'm using Komodo Edit) might use the wrong @INC variable, which could cause you problems - e.g. it might think you don't have a cpan module that you actually have installed.
You should be all set now. You should be able to install Perl modules without any problems.
Good luck!
UPDATE (03 Oct 2012): If you're using MacPorts, you can just use the following command:
sudo port install perl5 +perl5_14
But then when you install cpan modules, you have to use macports to install them.
1. Install Perl 5.14. Instructions are here. I downloaded the package from http://www.activestate.com/activeperl/downloads, opened the installer and installed the package. This part is easy and straightforward.
After this step, however, my Mac was still using Perl 5.12 rather than the new version. You can check which version your Mac is using by opening a terminal and typing:
perl -v
So you need to add the path to the new Perl version to your path.
2. Instructions for adding the path to the new Perl version to your path your Mac is here. More instructions on how to edit the path file (".profile" file in your user home directory) are available at http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/ and http://www.tech-recipes.com/rx/2618/os_x_easily_edit_hidden_configuration_files_with_textedit/. Doing this tells your Mac where to look for Perl when you type the perl command at the command prompt.
Your .profile file will be located in the "user home directory." For me, this is /Users/shafique. For you it will be whatever /Users/
env
or
echo $PATH
Now to add the new path to my path variable, I edited the .profile file using a text editor:
open ~/.profile
Go to the Text Editor, and add the following lines at the end of the text file that the editor just opened:
PATH=/usr/local/ActivePerl-5.14/bin:$PATH
PATH=/usr/local/ActivePerl-5.14/site/bin:$PATH
export PATH
Save and close the .profile file. Then go back to your terminal and type:
. ./.profile
echo $PATH
Yes, you will type out all three dots on this line. This adds the new Perl path to your environment PATH variable. Now you should be all set. To check which Perl version you are now running, type:
perl -v
and it should show that you are running version 5.14. If not, check your PATH variable:
env
or
echo $PATH
If it doesn't show that the new Perl version directory has been added to your PATH variable, then... well I don't know what to do.
3. Go ahead an install YAML. In your terminal window, type:
sudo perl -MCPAN -e 'install +YAML'
and then enter your password when the terminal asks for it.
4. Go ahead and upgrade CPAN. In your terminal window, type:
sudo perl -MCPAN -e 'install CPAN'
5. Uninstall previous versions of Perl:
sudo /usr/local/ActivePerl-5.14/bin/ap-uninstall
6. Remove all symbolic links to previous version of perl in the directories listed in your $PATH variable and replace them with symbolic links to the new versions. Start by finding out which paths may have outdated links:
echo $PATH
Here is what I had to do:
sudo rm /opt/local/bin/perl
sudo rm /opt/local/bin/perl
sudo rm /opt/local/bin/perl5
sudo rm /opt/local/bin/perl5.12
sudo rm /opt/local/bin/perl5.12.4
sudo rm /user/bin/perl
sudo rm /usr/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /usr/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /opt/local/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /opt/local/bin/perl
sudo ln -s /usr/local/ActivePerl-5.14/bin/perl /usr/local/perl
If you don't do this, then your editor (I'm using Komodo Edit) might use the wrong @INC variable, which could cause you problems - e.g. it might think you don't have a cpan module that you actually have installed.
You should be all set now. You should be able to install Perl modules without any problems.
Good luck!
UPDATE (03 Oct 2012): If you're using MacPorts, you can just use the following command:
sudo port install perl5 +perl5_14
But then when you install cpan modules, you have to use macports to install them.