Perl broken on El Capitan

I switched to El Capitan about a year ago. I have need to run Perl scripts periodically, and they ran fine before the upgrade. Now, they won't run at all. I get a lot of various errors. For example, one script that I ran previously gets the following error:


Can't locate HTML/Entities.pm: Permission denied at ./script.pl line 3.

BEGIN failed--compilation aborted at ./script.pl line 3.


Another is:

Can't locate POSIX.pm: Permission denied at ./script.pl line 3.

BEGIN failed--compilation aborted at ./script.pl line 3.


While trying just to run Perl debug mode (something I've done a lot in order to "test" things using the debug features), I get:


>perl -d

Can't locate perl5db.pl: Permission denied.

BEGIN failed--compilation aborted.


I *really* need to be running Perl soon for a project. But, it looks like Perl is completely messed up from the upgrade to El Capitan, or some upgrade to it that was done since the last time I was running Perl.

Can anyone give me step-by-step instructions on how to fix this, short of re-installing everything from scratch?


Thanks in advance.

MacBook Pro with Retina display, OS X El Capitan (10.11.6)

Posted on Mar 3, 2017 5:16 AM

Reply
17 replies

Mar 4, 2017 5:49 AM in response to sauljaffe

Your perl -V output matches mine. I have not installed additional CPAN modules. What do you see for the following:

User uploaded file

Was perl ok prior to adding those two CPAN modules, and can you fully uninstall them to see if proper functionality is restored?


At some point, and depending on how critical perl is to your day, you may find it more practical from a time investment to backup your machine, and in order, depending on whether your normal perl behavior is restored:

  1. Apply the 10.11.6 Combo Updater to your existing installation.
  2. Full reinstall of 10.11.6


In either case, apply all subsequent El Capitan updates.

Mar 4, 2017 2:46 PM in response to sauljaffe

I don't believe you ever answered my question if perl was working properly before installing those additional CPAN modules?


You have too many barriers that will stand in the way of determining why your system perl is not working properly:

  1. Time Machine backup is not working
  2. Unwilling to:
    1. El Capitan Combo Update
    2. Clean install El Capitan
    3. Install perlbrew

      Entire perl distribution inside a hidden folder in your home directory, and scripts that allow you to enable/disable/update/run that specific perl version.

  3. Ability to catalog any potentially wrong ownership/permissions in the entire System perl installation, or repair it without 2a/2b.
  4. No means to selectively reinstall System perl distribution without 2a, or 2b.

Mar 3, 2017 8:36 AM in response to sauljaffe

You will notice that all your errors point to permissions problems. In Ye Olde Days, Disk Utility used to have an explicit "repair disk permissions" feature, but alas no more. So, start up in Recovery Mode, run Disk Utility from there and do a First Aid on the startup volume. Hopefully that will tackle the problem.


If not, can try downloading the corresponding OnyX version for the OS and in the Maintenance tab run a Permissions verification and repair.

Mar 3, 2017 9:51 AM in response to sauljaffe

Nope:

mac:~ macjuan$ uname -a

Darwin mac.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64

mac:~ macjuan$ which perl

/usr/bin/perl

mac:~ macjuan$ perl --version


This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level

(with 2 registered patches, see perl -V for more detail)


Copyright 1987-2013, Larry Wall


Perl may be copied only under the terms of either the Artistic License or the

GNU General Public License, which may be found in the Perl 5 source kit.


Complete documentation for Perl, including FAQ lists, should be found on

this system using "man perl" or "perldoc perl". If you have access to the

Internet, point your browser at http://www.perl.org/, the Perl Home Page.


mac:~ macjuan$ perl -e '$_="krJhruaesrltre c a cnP,ohet";$_.=$1,print$2while s/(..)(.)//;'

Just another Perl hacker,mac:~ macjuan$


Have you tried with an Admin-enabled user account?

Mar 3, 2017 9:59 AM in response to Courcoul

This might also help in diagnosis. Note this is on a Mid-2015 rMBP running the stock-standard 10.11.6 ElCap that came installed with it, fully patched and up to date. I also have Fink and some extra stuff installed.


mac:~ macjuan$ perl -V

Summary of my perl5 (revision 5 version 18 subversion 2) configuration:


Platform:

osname=darwin, osvers=15.0, archname=darwin-thread-multi-2level

uname='darwin osx219.apple.com 15.0 darwin kernel version 15.0.0: fri may 22 22:03:51 pdt 2015; root:xnu-3216.0.0.1.11~1development_x86_64 x86_64 '

config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=cc'

hint=recommended, useposix=true, d_sigaction=define

useithreads=define, usemultiplicity=define

useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef

use64bitint=define, use64bitall=define, uselongdouble=undef

usemymalloc=n, bincompat5005=undef

Compiler:

cc='cc', ccflags ='-arch i386 -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector',

optimize='-Os',

cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector'

ccversion='', gccversion='4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)', gccosandvers=''

intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678

d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16

ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8

alignbytes=8, prototype=define

Linker and Libraries:

ld='cc -mmacosx-version-min=10.11.3', ldflags ='-arch i386 -arch x86_64 -fstack-protector'

libpth=/usr/lib /usr/local/lib

libs=

perllibs=

libc=, so=dylib, useshrplib=true, libperl=libperl.dylib

gnulibc_version=''

Dynamic Linking:

dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '

cccdlflags=' ', lddlflags='-arch i386 -arch x86_64 -bundle -undefined dynamic_lookup -fstack-protector'



Characteristics of this binary (from libperl):

Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS

PERL_DONT_CREATE_GVSV

PERL_HASH_FUNC_ONE_AT_A_TIME_HARD

PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP

PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL

USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES

USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE

USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF

USE_REENTRANT_API

Locally applied patches:

/Library/Perl/Updates/<version> comes before system perl directories

installprivlib and installarchlib points to the Updates directory

Built under darwin

Compiled at Aug 11 2015 04:22:26

%ENV:

PERL5LIB="/sw/lib/perl5:/sw/lib/perl5/darwin"

@INC:

/sw/lib/perl5/5.18.2/darwin-thread-multi-2level

/sw/lib/perl5/5.18.2

/sw/lib/perl5/darwin-thread-multi-2level

/sw/lib/perl5

/sw/lib/perl5/darwin

/Library/Perl/5.18/darwin-thread-multi-2level

/Library/Perl/5.18

/Network/Library/Perl/5.18/darwin-thread-multi-2level

/Network/Library/Perl/5.18

/Library/Perl/Updates/5.18.2

/System/Library/Perl/5.18/darwin-thread-multi-2level

/System/Library/Perl/5.18

/System/Library/Perl/Extras/5.18/darwin-thread-multi-2level

/System/Library/Perl/Extras/5.18

.

mac:~ macjuan$

Mar 4, 2017 4:33 AM in response to Courcoul

To answer some points:

- Yes, after repairing permissions, I rebooted the Mac. It did not fix the problem.

- I repaired the permissions on the Mac from Recovery Mode and rebooted again. It did not fix the problem.

- No, I do not have a non-standard set-up. I have whatever was dumped on my machine during install/updates and is whatever Apple provides with the possible exception of a couple of modules installed using CPAN.

- PERL does not work in "normal" mode. I can get it to work using sudo.


In the hopes that someone can spot something that I'm missing, I'm enclosing the output of "perl -V" when run using sudo:


Summary of my perl5 (revision 5 version 18 subversion 2) configuration:

Platform:

osname=darwin, osvers=15.0, archname=darwin-thread-multi-2level

uname='darwin osx219.apple.com 15.0 darwin kernel version 15.0.0: fri may 22 22:03:51 pdt 2015; root:xnu-3216.0.0.1.11~1development_x86_64 x86_64 '

config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=cc'

hint=recommended, useposix=true, d_sigaction=define

useithreads=define, usemultiplicity=define

useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef

use64bitint=define, use64bitall=define, uselongdouble=undef

usemymalloc=n, bincompat5005=undef

Compiler:

cc='cc', ccflags ='-arch i386 -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector',

optimize='-Os',

cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector'

ccversion='', gccversion='4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)', gccosandvers=''

intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678

d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16

ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8

alignbytes=8, prototype=define

Linker and Libraries:

ld='cc -mmacosx-version-min=10.11.3', ldflags ='-arch i386 -arch x86_64 -fstack-protector'

libpth=/usr/lib /usr/local/lib

libs=

perllibs=

libc=, so=dylib, useshrplib=true, libperl=libperl.dylib

gnulibc_version=''

Dynamic Linking:

dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '

cccdlflags=' ', lddlflags='-arch i386 -arch x86_64 -bundle -undefined dynamic_lookup -fstack-protector'



Characteristics of this binary (from libperl):

Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS

PERL_DONT_CREATE_GVSV

PERL_HASH_FUNC_ONE_AT_A_TIME_HARD

PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP

PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL

USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES

USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE

USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF

USE_REENTRANT_API

Locally applied patches:

/Library/Perl/Updates/<version> comes before system perl directories

installprivlib and installarchlib points to the Updates directory

Built under darwin

Compiled at Aug 11 2015 04:22:26

@INC:

/Library/Perl/5.18/darwin-thread-multi-2level

/Library/Perl/5.18

/Network/Library/Perl/5.18/darwin-thread-multi-2level

/Network/Library/Perl/5.18

/Library/Perl/Updates/5.18.2

/System/Library/Perl/5.18/darwin-thread-multi-2level

/System/Library/Perl/5.18

/System/Library/Perl/Extras/5.18/darwin-thread-multi-2level

/System/Library/Perl/Extras/5.18

Mar 4, 2017 6:08 AM in response to VikingOSX

The output of that command on my machine is:

-rwxr-xr-x 1 root wheel restricted,compressed 66720 Jul 8 2016 /usr/bin/perl


So it matches yours except for the date. That date appears to be when a patch of the OS was installed from Apple since it matches other dates on the system files. Again, I suspect the problem is due to something Apple did during a patch. I just don't know what.


I cannot re-install the OS from scratch. As I said earlier, I'm looking for a solution short of re-installing everything. One of the reasons is that, right now, I can't rely on my backups. I've been having problems with the Time Capsule backups. When it rains, it pours... In any event, I cannot initiate a backup. It fails repeatedly telling me that Time Capsule wants to start a new backup. That will wipe everything on there now. If the disk is bad, or there's some other problem, I may not be able to back up the machine or re-install from it. But, that's a discussion for another thread.


In the meantime, is there anyway to just force a re-install of Perl and see if that fixes things? Right now, it's just weird because everything points to a permissions problem, yet fixing the permissions doesn't fix it. Again, I'm wondering if the new security features that Apple implemented has broken something. On the other hand, both php and Python are working normally as far as I can tell (I don't use either much) and Perl is the only software I've discovered that's not working correctly.

Mar 4, 2017 12:04 PM in response to sauljaffe

There is of course, perlbrew, that lets you install an entire perl distribution, including CPAN in your home directory, and allows you to switch between it and the system perl.


More on perlbrew.


I use a patched version of the discontinued pythonbrew in the same manner, but do not personally use perlbrew myself.


The El Capitan perl is installed by the operating system, and you cannot specifically reinstall it without reinstalling the operating system — hence the perlbrew suggestion.


Your Time Capsule may be gasping its last, and it may be time to bail to a new external backup drive.

Mar 4, 2017 12:41 PM in response to VikingOSX

I prefer not installing other versions of "standard" software because it's just more to maintain and more things that can go wrong. I'd really like to figure out what the problem is with the system Perl... especially since there's no guarantee that installing perlbrew will work (if it's something other than a permission problem, like for instance something wrong with the basic security set-up).


As for the Time Capsule: you may be right. It's 2.75 years old now. Unfortunately, I'm more than broke. :-(

Mar 4, 2017 3:35 PM in response to VikingOSX

PERL was working fine on the system until the El Capitan update. I said that early on. I also said that I hadn't done anything with PERL since the update. Logically it follows then that PERL was working after the CPAN modules were installed. I don't see how whether or not PERL was working before then is relevant.


As for the rest:

1. Whether or not Time Machine backup is working has nothing to do with why PERL is not.

2. My unwillingness to:

a. Install El Capitan Combo Update (which I'm not entirely sure hasn't been done already) is not relevant to why PERL is not now working. I say that I'm not sure if it hasn't been installed already is because according to Apple's update procedures, my machine is up to date.

b. Clean install of El Capitan also won't explain why PERL is not working. There's no evidence that it will fix the problem.

c. Installing perlbrew will not fix the Apple distributed version of PERL. I will not get into a philosophical discussion as to whether perlbrew is better or worse than the system version, or entirely compatible. It's not relevant.

3. I'm not sure what you mean by this. I've already said that I've repaired the ownerships/permissions in two different ways: with Onyx and Disk Utility in Recovery Mode. As for "cataloging" any potentially wrong ownerships/permissions... do you have a file that gives what they should be for every file? If *you* can catalog the correct ownerships/permissions, I can check each file manually.

Mar 4, 2017 4:26 PM in response to sauljaffe

There is a buried tool named repair_packages in /usr/libexec. It has a man page by that name. It will allow you to verify, and repair an entire OS X package's permissions.


Before you can run it, you need to temporarily disable the System Integrity protection (SIP) that is protecting the System locations.

See this article if you don't already know how.


When you have rebooted from disabling SIP, then do the following (one contiguous command, no intentional wrap):

sudo /usr/libexec/repair_packages --verify --pkg com.apple.pkg.Essentials >& ~/Desktop/verify.txt

It runs through the entire package in about 2 minutes, and will report any permissions issues it encounters. Eventually, it will come to the Perl installation hierarchy. I redirected to a text file so that you could search for the verify results in that hierarchy.


If there are permissions that need fixing, then the following should do the job:

sudo /usr/libexec/repair_packages --repair --pkg com.apple.pkg.Essentials >& ~/Desktop/repair.txt

When this is done, check if perl is now behaving for you. Then, reboot into Recovery, re-enable SIP, and then reboot normally. If this repair_packages doesn't get the job done, then I am out of ideas.

Mar 8, 2017 9:35 AM in response to VikingOSX

I'm now convinced that it's not a permissions problem. Note the following:

> sudo perl -d test.pl

Loading DB routines from perl5db.pl version 1.39_10

Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(test.pl:3): for ($i = 0, $i <= 10, $i++){

DB<1> l

3==> for ($i = 0, $i <= 10, $i++){

4: print $i,"\n";

5 }

DB<1> c

1

1

1

Debugged program terminated. Use q to quit or R to restart,

use o inhibit_exit to avoid stopping after program termination,

h q, h R or h o to get additional info.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Perl broken on El Capitan

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.