Programming languages often have their own packaging system to resolve dependencies. For [http://www.perl.org Perl] this would be [http://www.cpan.org/ CPAN], for Ruby this would be [http://rubygems.org/ "Ruby gems"].
When it comes to [http://www.gentoo.org Gentoo] and programming languages the [http://packages.gentoo.org/package/sys-apps/portage?arches=all package system of Gentoo (Portage)] and the package system of the language collide. That's mostly because the Gentoo developers think they have to resolve all dependencies by the Gentoo Portage System.
If you have read my old article about [http://www.klumpp.net/blog/archives/116-Gentoo-Linux-and-Ruby...html "Gentoo Linux and Ruby"] you know what I mean.
Gentoo and Perl CPAN have a quite similar problem. The Perl Package Management does not honor Gentoo (with a good default permission set) and Gentoo can't honor already installed CPAN packages and to resolve its own Portage dependency hell.
++ The Problem
So, once you install a package with CPAN by:
cpan install Net::Twitter::Lite
You end up with permissions that won't let your users find the newly installed module. Instead they find the following error message slightly amusing:
Can't locate Net/Twitter/Lite.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/siteperl/5.12.4/i686-linux-thread-multi /usr/lib/perl5/siteperl/5.12.4 /usr/lib/perl5/vendorperl/5.12.4/i686-linux-thread-multi /usr/lib/perl5/vendorperl/5.12.4 /usr/lib/perl5/siteperl/5.12.3/i686-linux-thread-multi /usr/lib/perl5/siteperl/5.12.3 /usr/lib/perl5/siteperl/5.12.2/i686-linux-thread-multi /usr/lib/perl5/siteperl/5.12.2 /usr/lib/perl5/siteperl /usr/lib/perl5/vendorperl /usr/lib/perl5/5.12.4/i686-linux-thread-multi /usr/lib/perl5/5.12.4 /usr/local/lib/site_perl .) at ./twitter.pl line 12.
BEGIN failed--compilation aborted at ./twitter.pl line 12.
The permission are:
ls -l /usr/lib/perl5/site_perl/5.12.4/Net/Twitter
drwxr-x--- 2 root root 4096 Jun 16 17:53 Lite -r--r--r-- 1 root root 143714 May 8 18:06 Lite.pm That's the problem. Other users don't have read access on the Perl package directories by default!
++ Gentoo developers like complexity The Gentoo developers will hint you to [http://www.gentoo.org/proj/en/perl/g-cpan.xml G-CPAN] and [http://search.cpan.org/~vpit/CPANPLUS-Dist-Gentoo-0.12/lib/CPANPLUS/Dist/Gentoo.pm CPANPLUS]. But, I for myself don't like the ways mentioned there.
++ The Easy Fix What is the easiest fix for you and for me?
Be pragmatic, as root do:
cd /usr/lib/perl5
find -type d | xargs chmod o+rx
find -type f | xargs chmod o+r
Done.
Of course you can put those lines in your own shellscript for a quicker execution. Whenever I install a Perl CPAN package as root I start that simple shellscript.