1

perl 5.18.2 was running fine on my Ubuntu 14.04 system until I needed a package from CPAN which did not exist as an Ubuntu package. I installed it as root and it didn't work but then the installation process seems to have changed permissions of something. Now, I cannot run Perl as a normal user.

As a normal user, "perl -v" works. But "perl -V" gives me this:

$ perl -V

Can't locate Config.pm:   Permission denied.
BEGIN failed--compilation aborted.

If I run it under sudo, then it works:

$ sudo perl -V

...
@INC:
  /etc/perl
  /usr/local/lib/perl/5.18.2
  /usr/local/share/perl/5.18.2
  /usr/lib/perl5
  /usr/share/perl5
  /usr/lib/perl/5.18
  /usr/share/perl/5.18
  /usr/local/lib/site_perl
  .

Indeed, Config.pm exists in /usr/lib/perl/5.18 and its permissions are readable by normal users. So, something has switched to root and I don't know what has.

Has anyone seen this before and know what I should be looking for? Out of desperation, I even uninstalled perl and reinstalled it back. Didn't work. Though something funny...after uninstalling, I still had a /usr/bin/perl executable. Not sure if that is related...

Any help would be appreciated!

Ray

Ray
  • 2,071
  • From some googling (see here) I understand that if one of the directories in the @INC path is inaccessible, the search for Config.pm (or any module) is abandoned. So check whether any of the directories is not readable by "all". – Jos Jun 30 '14 at 11:23
  • Thank you for your help! I did try using Google but I was coming up with page after page from users who didn't "chmod u+x" their Perl scripts. Maybe I wasn't thinking clearly and was just putting in the wrong keywords into Google. Anyway, your solution was it. One of the folders in INC was missing -- that is fine. But one of the folders in INC had its permissions changed by my module installation. That was the problem, even though it didn't have a *.pm that I was using. Please feel free to post a solution that I can accept. Thank you very much! – Ray Jul 03 '14 at 08:44
  • I have non-existent directories in the path myself. Strange that that is no problem. Anyway, good to see your problem solved. – Jos Jul 03 '14 at 09:02
  • Yes, the problem was a directory in INC which was owned by root and changed to just root accessible. I've "sudo" to do a module installation; this is the first time, such a procedure made it unreadable to normal users. Thank you again for the help! Indeed, I panicked a bit and didn't think clearly enough to figure out how to Google properly... – Ray Jul 03 '14 at 15:47

2 Answers2

1

From some googling (see here) I understand that if one of the directories in the @INC path is inaccessible, the search for Config.pm (or any module) is abandoned. So check whether any of the directories is not readable by "all".
Strangely enough, a non-existent directory name in the @INC path is no problem.

Jos
  • 29,224
  • I got the same error when all my INC directories were accessible (or missing), but I had an inaccessible directory in PERLLIB environment variable. – Seppo Enarvi Dec 14 '14 at 20:52
1

You can try install local::lib. But you'll probably have to reinstall some Perl modules.

  1. sudo apt-get install cpanminus

  2. cpanm --local-lib=~/perl5 local::lib eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)

  3. echo "export PERL5LIB=\"$HOME/perl5/lib/perl5\"">>~/.bashrc && echo "export PERL_MB_OPT=\"--install_base '$HOME/perl5'\">>~/.bashrc && echo "export PERL_LOCAL_LIB_ROOT=$HOME/perl5">>~/.bashrc

Now, open a new terminal(or run source ~/.bashrc) and try to install some Perl module.

Works for me! Hope works for you too! Otherwise, that means your CPAN installation is broken. In this case, use command sudo dpkg --list | grep libcpan to list all cpan's packages, try to upgrade packages at first.

If still doesn't work try to remove and reinstall all of them! After that, install local::lib again repeating the steps above.

TheWanderer
  • 19,395
  • 12
  • 50
  • 65