Link to home
Start Free TrialLog in
Avatar of Airgazm
Airgazm

asked on

Can't locate strict.pm in @INC

Hi there, having a problem with perl.

I get this error when trying to run any perl script.

###
Can't locate strict.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.0/i686-linux /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .) at test line 2.
BEGIN failed--compilation aborted at test line 2.
###

But I do not get the error when;
I am logged in as Root or,
I remove the line "use strict;"

I am actually running perl 5.6.1, I tried to install 5.8.0 a while back and it totally buggered my system and I had to restore from backup, but somehow it still see's the old perl.

If I do a perl -V I get this back,
@INC:
    /usr/local/lib/perl/5.6.1
    /usr/local/share/perl/5.6.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.6.1
    /usr/share/perl/5.6.1
    /usr/local/lib/site_perl/i386-linux
    /usr/local/lib/site_perl

So @INC seems to know where to go.

This is very strange, I don't understand where perl is getting this info from, and why it only does it as a normal non SU user.

I removed all files pertaining to 5.8.0, there is nothing in my system for perl 5.8.

This was a Debian package install, I just reinstalled the latest copy and still get the error.

Does anyone know what is happening here?

Thanks for help.

-Air

Avatar of tomclegg
tomclegg

Shot in the dark here.  Try this (as NON-root user):

shell$ for d in /usr/local/lib/perl/5.6.1 \
   /usr/local/share/perl/5.6.1 \
   /usr/lib/perl5 \
   /usr/share/perl5 \
   /usr/lib/perl/5.6.1 \
   /usr/share/perl/5.6.1 \
   /usr/local/lib/site_perl/i386-linux \
   /usr/local/lib/site_perl \
 ; do ls -ld $d >/dev/null && [ -e $d/strict.pm ] && ls -l $d/strict.pm; done

See if you get any "permission denied" errors.  It's conceivable that strict.pm is only readable by root.  I can't think why this would happen, but at least it's a nice easy thing to check.  :)
Check if after installing 5.8 you have the following directories
/usr/local/lib/perl/5.8.0
/usr/local/share/perl/5.8.0
/usr/lib/perl/5.8.0
/usr/share/perl/5.8.0

If they are present then you can have two options:
[1] Change the @INC at compile time using 'lib' module

BEGIN { unshift(@INC, list of new directories to be added) }  

[2] Change the variable "PERL5LIB" to point to the path for 5.8 in your profile file.
Avatar of Airgazm

ASKER

tomclegg, ahh.

This is what I get back after running that as non root.

-rw-r--r--    1 root     root          377 Nov 30 10:01 /usr/share/perl/5.6.1/strict.pm

I see that strict.pm is owned only by root, should I change this, maybe it needs to be grouped or something.
ASKER CERTIFIED SOLUTION
Avatar of tomclegg
tomclegg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Airgazm

ASKER

tomclegg, I had a friend helping a bit ealier and finally got by the problem. You were on the correct path with your last answer.

Turns out running as non su, Perl was using /usr/local/bin/perl and using su, perl was using /usr/bin/perl

But I checked the dates on /usr/local/bin/perl and found it to be the old 5.8 version, so looks like the debian package install won't write over this, so uninstalling wasn't an option, it would have removed 42 other packages, ouch, so I just recompiled 5.8.0 again, and boom, everything works now.

I am having a couple of module problems now with DBD::mysql but I don't think they are related to this.  

I don't know why the debian package wouldn't just reinstall over this binary, oh well.

Thanks for your help though.
One point of clarification:

In Perl 5.8.5 and earlier "use strict;" was a pragma and strict.pm did not exist.

From Perl 5.8.8 on strict.pm DOES exist and the Perl interpreter will look for it if you "use strict;". But it's still pragma.

So you can hit the same problem when upgrading from versions of Perl 5.8.5 and earlier to versions of Perl 5.8.8 and later. Just make sure you whack any old versions of Perl and get your @INC paths right.
Ah. Sorry -- that's not a clarification at all. :-)

It's not that strict.pm does not exist in earlier versions just that when upgrading, Perl constructs an @INC which includes "site_perl" modules from the earlier version, but does not include standard modules from the earlier version.

Aaaaaanyway...