Pernicious Perl Path Permission Problems

I ran into a situation where I somehow managed to hork up a perl installation by having the temerity to install some perl modules. From them on, invocations of perl by anyone other than root result in disappointment:

Here’s how I fixed it.

The problem is that somewhere in Perl’s module inclusion path ( @INC in perl terms) there is at least one directory which is not readable or executable by normal users on your system.

No, I don’t know how it happened. My guess in my case is that CPAN honored my system’s UMASK=077 a little too diligently. I saw some threads via google search where people seem to cause this behavior by somehow including a non-readable path in their system-wide perl @INC path, most commonly something under /root/.

Perl made a change recently. In the long-long ago, when perl found a directory it couldn’t read due to permissions errors it would just keep going and check the rest of the @INC paths. Now, it just gives up and dies.

Let’s find all of those bad directories:

This is a for-loop which loops over the output of the perl command. That perl command is a little one-liner which prints out the list of module paths (you can pull out the portion between the `’s and run it by itself to see). Then it uses the find command, starting at each entry in perl’s @INC path, to view each directory under that path. At the end is some output redirection. First, we tell it to redirect errors into standard output (2>&1), and then we tell it to throw away the standard output. What I want are only the errors.

In the output we see two errors of note. We don’t have permission to read /usr/local/share/perl/5.20.2 . We also can’t find /usr/local/lib/site_perl . Turns out the second one isn’t an issue. Perl doesn’t care about directories it can’t find. It’s the permissions errors we have to fix.

I started at the listed directory and tried to view the permissions ( ls -al ). That didn’t work, so I worked my way up the directory tree until I could view the permissions. Finally I found the problem:

That directory’s permissions are screwed up! Way on the left we have drwxr-x--- . The ‘d’ means it’s a directory. Then the next three items are the owner’s permissions (read, write, and execute), then the permissions of the file’s group (read, and execute), finally, the permissions for other users (e.g. most regular users), which are nothing.

In order for users to be able to use perl the path needs to have read and execute permissions for other users.

In fact, all of the directories under there should be set that way:

This find command searches for all of the directories (-type d) found under /usr/local/share/perl  and then executes chmod on all of them. The {}  is a placeholder for whatever find found.

And that’s it. Perl works!