8

I updated to Mountain Lion 4 days ago and then realised that my perl scripts did not work any longer. So I installed ActivePerl 5.14 (newest version) because I thought that perl has been deleted. After installing ActivePerl though my programmes still did not work:

Warning message:
running command 'perl calc.pl' had status 2 
Can't locate Excel/Writer/XLSX.pm in @INC (@INC contains:    
/Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 
/Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 
/Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level 
/System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-
2level /System/Library/Perl/Extras/5.12 .) at test.pl line 3.
BEGIN failed--compilation aborted at calc.pl line 3.

In the terminal when I type perl -v it shows that it uses the newly installed ActivePerl. I used sudo clan -> install Excel::Writer::XLSX to install the missing module. However, it does not install it for 5.12 but for ActivePerl 5.14.

The own Mac OS X Perl seams to be installed here:

bash-3.2$ ls /Library/Perl/
5.10    5.12    Updates
bash-3.2$ ls /System/Library/Perl/
5.10    5.12    Extras  lib
bash-3.2$

There is also a version here:

bash-3.2$ ls /opt/local/lib/perl5/
5.12.4      site_perl   vendor_perl

I thought best is to delete the ActivePerl by running its uninstaller. I did that and also removed the 5.12.4 as well as the site_perl directory in /opt/local/lib/perl5.

Then I wanted to reinstall the XLSX::Writer module using cpan. I thought that it is then installed into the old perl directory. However running cpan now results in the following error:

bash-3.2$ sudo cpan
Can't locate strict.pm in @INC (@INC contains:    
/opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level 
/opt/local/lib/perl5/site_perl/5.12.4 
/opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level 
/opt/local/lib/perl5/vendor_perl/5.12.4 /opt/local/lib/perl5/5.12.4/darwin-multi-
2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl5/site_perl 
/opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level 
/opt/local/lib/perl5/vendor_perl/5.12.3 /opt/local/lib/perl5/vendor_perl .) at 
/opt/local/bin/cpan line 5.
BEGIN failed--compilation aborted at /opt/local/bin/cpan line 5.

I don't know what to do now. I think the best I can do is probably reinstalling Mac OS X's own Perl, how to do that?

  • Do you have macports installed? guessing from /opt/local/bin – user151019 Jul 31 '12 at 11:38
  • yes I do. I just reinstalled xcode and the developer command line tools but still the same... I might just reinstall my whole system and restore some of my stuff via time machine. Wouldnt heart to have a clean system anyhow... – user26392 Jul 31 '12 at 11:56
  • You need to decide what perl to use - Apple's, macports or activestate and then make sure only one appears in @INC - tell us which one then we can help – user151019 Jul 31 '12 at 11:58
  • well, I want to use apples perl but to be able to use it I also need to install the XLSX.pm module for that version of perl. However, because of deleting some folders I cannot start cpan any longer... what you think is best to do? – user26392 Jul 31 '12 at 12:21
  • Which directories did you delete? – user151019 Jul 31 '12 at 12:30
6

I found on another website the following command

$ sudo perl -MCPAN -e 'CPAN::Shell->notest(install => CPAN::Shell->r)'

This updated all my perl modules and all is back to normal. Not sure why or what, but don't care that it is working now.

0

For various and sundry reasons upgrading the OS requires one to separately upgrade/reinstall MacPorts. The developers have actually created a pretty nice Migration page that details the process necessary to get your ports environment working again after upgrading the OS.

Summarized, the steps you need to follow are:

  1. Download and install new Xcode.
  2. Make sure command line (gcc, make, etc.) tools are installed. From within the Xcode application go to Preferences->Downloads and install them.
  3. Download the MacPorts installer of choice for your OS version.
  4. Install it.
  5. Open your terminal of choice.
  6. Run the command port -qv installed > myports.txt. This grabs a copy of all installed ports.
  7. Uninstall all the ports: sudo port -f uninstall installed
  8. Tidy up your play area: sudo port clean all
  9. Go through the file myports.txt and reinstall the packages you actually want.

I actually sped up my reinstall process by editing the myports.txt file, such that it contained the names (and only the names) of the packages I wanted with one package per line, and running the following command

cat myports.txt | xargs -n1 port install

What this does is go through that file and execute the command port install line for every line in the file. It is a useless use of cat, butwho cares, it's easier to read.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .