Как добавить модули Perl с использованием CPAN на El Capitan

3437
John Wooten

Когда появилась OS X El Capitan, возможность использовать CPAN для добавления или обновления модулей Perl исчезла. Кажется, что сценарии либо хотят изменить /usr/bin, что сейчас запрещено, либо пытаются использовать двоичные файлы, /sw/usr/binкоторых нет и /usr/binвместо них. Сам Perl не может быть установлен, потому что он хочет установить /usr/binвместо /usr/local/bin.

Где скрипты, которые их используют /sw/usr/bin? Кажется, они должны использовать PATH, чтобы найти двоичные файлы, а не жестко их кодировать.

Кто-нибудь знает, как починить Perl и CPAN на El Capitan? Подробные инструкции будут полезны.

2

1 ответ на вопрос

2
Tonin

I had no issue adding new CPAN packages to the OSX El Capitan shipped perl. By default, they are built in your home directory and installed in /Library/Perl/5.18/ which is writable with root privileges.

The /sw/ prefix you mention seems to come from a Fink installation. If you previously installed another perl from Fink, you probably need to update your Fink installation and update the perl package coming from it.

If you're sure you're not using Fink and you want to run another perl version alongside the one provided with OS X, you can use the one from homebrew. It will install in /usr/local and will be available for you to call it, but all OSX perl programs will keep on using the perl version shipped with OSX. Beware that Fink and Homebrew don't play well with each other, it is better to stick to a single one.

Finally, if you want to run multiple perl versions and be able to switch back and forth between those, I'd suggest you have a look at perlbrew.

Some other useful commands to debug your perl installation further:

  • which perl will tell you where your current perl exec is installed
  • perl -V will give you more information about the perl version, its compiled date and options and the include paths that are searched for modules
  • perldoc perllocal will list you the perl modules that you installed locally with CPAN

About CPAN, as you noticed, a regular CPAN upgrade fails. There is however a solution by telling CPAN to install in /usr/local/bin/. I have documented that CPAN upgrade in this answer.