Are you facing error "Can't locate LWP/UserAgent.pm in @INC"?
This guide will help you.
Sometimes in the process of installing applications such as CSF in the DirectAdmin server or any other Linux distros like CentOS or Ubuntu, users get "Can't locate LWP/UserAgent.pm in @INC" error.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix Linux related issues.
In this context, we shall look into the causes of this error and how to get rid of it.
Nature of error "Can't locate LWP/UserAgent.pm in @INC"?
When this error occurs, you will see an error message such as this:
Can't locate LWP/UserAgent.pm in @INC (@INC contains: /usr/local/cpanel /etc/csf /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /etc/csf/csf.pl line 1798.
BEGIN failed–compilation aborted at /etc/csf/csf.pl line 1798.
Basically, this error trigger when applications such as CSF require Perl to compile and Perl is not installed on the server.
More about Perl ?
Perl is a programming language to perform tasks that would be difficult or cumbersome on the command line.
Most of the GNU/Linux distributions include Perl by default. Usually, we can invoke Perl using a text editor to write a file and then pass it to the Perl program.
Practical Extraction and Report Language was a language to scan arbitrary text files, extract, and print reports based on that information. Being a good language for many system management tasks, Perl has grown into a general-purpose programming language.
We can locate Perl wherever we choose. However, it’s best for both /usr/bin/perl and /usr/local/bin/perl to be symlinks to the actual binary.
Being popular in demand, Perl has several advantages, which includes:
i. Easy to start: It is closer to programming languages like C, C++ and thus, easy to learn.
ii. Text-Processing: Perl has high text manipulation abilities by which it can generate reports from different text files easily.
iii. Contains best Features: It contains features of different languages making it more useful and productive.
iv. System Administration: Since it has different scripting language capabilities Perl makes the task of system administration very easy.
How to fix error "Can't locate LWP/UserAgent.pm in @INC"?
To begin, we can install Perl by running:
# perl -MCPAN -e 'install Bundle::LWP'
However, in CentOS/RHEL, we run:
# yum install perl-libwww-perl
Similarly, in Ubuntu/Debian, we run:
# apt-get install libwww-perl
We can compile Perl from the source:
# wget http://www.cpan.org/modules/by-module/LWP/libwww-perl-6.06.tar.gz
# tar xvzf libwww-perl-6.06.tar.gz
# cd libwww-perl-6.06
# perl Makefile.PL
# make install