Perl Module Location Issue
Matthew Barrera
I'm on Ubuntu 20.04 LTS.
I ran the following commands to try to connect to my PostgreSQL database:
sudo -i -u postgres
postgres@{username}:~$ psqlThis raised the following error:
Can't locate warnings.pm: /usr/local/lib/x86_64-linux-gnu/perl/5.30.0/warnings.pm: Permission denied at /usr/bin/psql line 19.What I subsequently discovered is that the directory '/usr/local/lib/x86_64-linux-gnu' doesn't exist, so of course '/usr/local/lib/x86_64-linux-gnu/perl/5.30.0/warnings.pm' cannot be located. Running the command perl -e 'print "@INC";' | tr " " "\n" gave me the following results:
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.30.0
/usr/local/share/perl/5.30.0
/usr/lib/x86_64-linux-gnu/perl5/5.30
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.30
/usr/share/perl/5.30
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-baseThis seems to reveal the issue, as none of the paths here that begin with '/usr/local' actually exist (the others do, however). Is it possible to resolve this problem by changing the perl paths using .bashrc? If so, what precisely do I write? (I have looked this up but got confused.) And can anyone explain why this has happened?
1 Answer
The solution to this turned out to be exactly what I suspected: I just had to edit my PERL5LIB path so that the paths not containing '/local/' come first. I have changed my .bashrc to export PERL5LIB=/usr/share/perl/5.30:/etc/perl:/usr/lib/x86_64-linux-gnu/perl5/5.30:/usr/share/perl5:/usr/lib/x86_64-linux-gnu/perl/5.30:/usr/lib/x86_64-linux-gnu/perl-base. Still a little mystified as to how this happened though - as to why these paths are set that don't point to anything.