Ubuntu – Installing libwww-perl on Ubuntu 12.04,SE

12.04perlssh

I have an Ubuntu 12.04 server edition which I ssh into.

I am running Perl scripts on this server but it fails when I load

'use LWP::UserAgent;' with error message:
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /home/hermann/scripts/modules/ /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at 1_standalone line 5.
BEGIN failed--compilation aborted at 1_standalone line 5.

So in order to fix that I am trying to install LWP::UserAgent, which I am told is by:
sudo apt-get install libwww-perl

But when I run that command i get the following error:

Failed to fetch http://is.archive.ubuntu.com/ubuntu/pool/main/libf/libfont-afm-perl/libfont-afm-perl_1.20-1_all.deb  Size mismatch
Failed to fetch http://is.archive.ubuntu.com/ubuntu/pool/main/libh/libhtml-tagset-perl/libhtml-tagset-perl_3.20-2_all.deb  Size mismatch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Now I have tried doing sudo apt-get update, which appears to run fine but doesn't change anything.
And I have also done 'sudo apt-get install libwww-perl –fix-missing', which also fails.

How do I install libwww-perl?

Best Answer

First, I would strongly advise against the direct 'perl way' installs, they will only make the mess bigger. You don't need these in Ubuntu. libwww-perl exists as a standard Ubuntu package.

Since this doesn't work. You should start by cleaning up your installation which seems to be broken. First, try cleaning-up your package installs like this:

sudo apt-get install -f
sudo apt-get update --fix-missing

and only when you don't get errors, move on to installing libwwww-perl, using:

sudo apt-get install libwww-perl

Also:

You seem to have a very unusual (non-standard) list of directories perl is searching libraries in. For example, there shouldn't be a /etc/perl in the places to look for libraries, and on Ubuntu you don't need anything starting with /usr/local.

To check whether the package is installed, you may check the output of:

dpkg-query -S libwww-perl

Check your env for bad forced perl paths:

env | grep PERL

If this gives any output, I would remove it from the environment before running perl: Look at your startup files (~/.bashrc in particular end comment these non standard settings out)

Good luck!

Related Question