Mac OS X Perl: Can't locate Config/IniFiles.pm Error

Mac OS X Perl: Can't locate Config/IniFiles.pm Error

December 27, 2014

I ran into an interesting Mac OS X Perl issue the other day. Since @runlevelmedia hosts websites for clients, its a good idea to have a backup strategy. Hoping and prayer is not really strategy.

We have been working on updating our backup plan to make it more efficient. Basically, the script could be run from different machines, so we have multiple copies as a starting point.

Testing out the script on my Macbook threw me for a surprise. Apparently, I mostly use the basic Perl modules pre-installed with Mac OS X and I’d never run across any issues.

1
jeebus:~ nali$ ./backup.pl —config testconfig.iniCan’t locate Config/IniFiles.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at ./backup.pl line 3.BEGIN failed—compilation aborted at ./backup.pl line 3.

(Yes, my Macbook name is jeebus). Quick Googling found people complaining about the Perl version installed by Mac OS X. The problem is that its not the best idea to yank out the pre-installed version because a lot of apps and systems related processes expects it all work in a certain way. One example I saw was how iTunes used a string comparison behavior that got changed in the more recent versions of Perl. So lots of folks end up installing a bunch of different versions of Perl, which is beyond confusing and unmanageable.

Turns the following command makes it pretty easy to install specific CPAN modules:

1
sudo perl -MCPAN -e ‘install Config::IniFiles’

Another option is to kick off a CPAN shell and install that way:

1
sudo perl -MCPAN -e ‘shell’Terminal does not support AddHistory.cpan shell — CPAN exploration and modules installation (v1.9205)ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)cpan\[1\]> install Config::IniFilesCPAN: Storable loaded ok (v2.18)Going to read /Users/nali/.cpan/Metadata….

That’s it!