How to resolve #INC related issue in Perl - perl

I am getting the following error, while run the perl script.
Can't locate File/stat.pm in #INC (you may need to install the File::stat module) (#INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/local/share/perl/5.24.1/Path/Class/Entity.pm line 9.
I have tried to install the missing package thorugh CPAN install.
When i tried CPAN ,I am getting the following error
Can't locate File/Find.pm in #INC (you may need to install the File::Find module) (#INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl/5.24/CPAN/CacheMgr.pm line 8.
Can u please any one help me to resolve the issue.

File::stat has been a part of the standard Perl distribution since Perl 5.004 in 1997. There should never be a reason to install it separately. If you find yourself in that situation, then something has gone badly wrong in your Perl installation and I would strongly suggest reinstalling from scratch using the pre-built packages supplied by your Linux distribution.

Related

Can't locate XML/Writer.pm in #INC . Cant locate DBD/CSV.pm in #INC

I tried using CPAN module XML::Writer, but I am getting following error:
Can't locate XML/Writer.pm in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at testing.pl line 3.
BEGIN failed--compilation aborted at testing.pl line 3.
I checked for installation of the module using - perldoc XML::Writer and the document doesn't seems to be exist.
As I don't have the privilege to install the package as I am not the system administrator.
I have similar error for DBD::CSV too.
What can be done if a particular CPAN module not available/installed in the server where I am working and how do I install it without admin access?
Just an idea. I can't write this as an comment, because I'm a new user here and have not enough reputation to do this.
You can download the module files as XML-Writer-0.625.tar.gz from CPAN website https://metacpan.org/pod/XML::Writer and extract it in the same folder as your perl file.

Which modules are missed?

On my system:
$ uname -ra
Linux web.feel-safe.net 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
I get next errors while installing modules:
Can't locate inc/ExtUtils/MY_Metafile.pm in #INC (you may need to install the inc::ExtUtils::MY_Metafile module) (#INC contains: /home/feelsafe/web/local/lib/perl5/x86_64-linux-gnu-thread-multi /home/feelsafe/web/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at Makefile.PL line 4.
BEGIN failed--compilation aborted at Makefile.PL line 4.
.
Configuring List-MoreUtils-0.416
Running Makefile.PL
Can't locate inc/latest.pm in #INC (you may need to install the inc::latest module) (#INC contains: /home/feelsafe/web/local/lib/perl5/x86_64-linux-gnu-thread-multi /home/feelsafe/web
/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/per
l/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at Makefile.PL line 51.
BEGIN failed--compilation aborted at Makefile.PL line 51.
.
Configuring MRO-Compat-0.12
Running Makefile.PL
Can't locate inc/Module/Install.pm in #INC (you may need to install the inc::Module::Install module) (#INC contains: /home/feelsafe/web/local/lib/perl5/x86_64-linux-gnu-thread-multi /home/feelsafe/web/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
-> N/A
-> FAIL Configure failed for MRO-Compat-0.12. See /home/feelsafe/.cpanm/work/1524673518.17946/build.log for details.
Currently I have found this article, but still do not understand the problem.
What did I miss on my system? And what is the problem?
Because I use Carton to deploy my application:
carton install --deployment
I have List-MoreUtils-0.416 in my cpanfile.snapshot. Thus I use old module version which relies on "." exists at #INC.
But on target host, where I was faced into Can't locate inc/latest.pm in #INC problem there is DEBIAN perl-5.24.1 which apply patch from perl-5.26 which removes '.' from #INC
Because of this inc::latest is not found in bundled directory
To resolve my issue I just add next line into cpanfile:
requires 'List::MoreUtils', '>=0.428'
Unfortunately carton update do not update all modules from cpanfile.snapshot just only mentioned at cpanfile.
Also, I think, it will be OK to install inc::latest
You may be using the "system" perl (cf. perlbrew) where the library paths in %INC assume modules are installed using the operating system's package manager.
When building modules it's sometimes easier to use a locally built perl, a module "bootstrapping" utility like local::lib, or perlbrew to manage your "non-system" instance of perl. This allows you to easily avoid mixing module packages installed by the OS with your own locally built modules.

New version of Perl messed up #INC

I'm using Linux Mint 17.
I've installed Perl version 5.20 over 5.18 version and now I have problems with installing new modules, because cpan is installing then into 5.20 folders, but #INC contains only:
(#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2
/usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18
/usr/local/lib/site_perl .)
What is the best solution for this mess? Should I just add new 5.20 folders into #INC or is it too dirty way and I should somehow delete previous Perl version or even redo it all over again?
Tahnks a lot.
As Quentin suggested, NEVER touch your system's Perl. Use local::lib or perlbrew.
What you can do now is to use your distro's package manager to uninstall and install Perl, then leave it as it is and install perlbrew.

CPAN module installation problems

I have installed cpan module by cpan install semantics3 and cpanm install semantics3 but still it is throwing error like this
Can't locate Net/Semantics3.pm in #INC (you may need to install the Net::Semantics3 module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at extraction.pl line 1.
BEGIN failed--compilation aborted at extraction.pl line 1.
You need to specify the whole module name for installation, not just the last part. Thus, your command should be
cpan Net::Semantics3
instead of just install semantics3.
From its GitHub repo, you can try:
perl -MCPAN -e "install Net::Semantics3"

Can't locate Bench.pm in #INC [Perl] [duplicate]

This question already has answers here:
What's the easiest way to install a missing Perl module?
(24 answers)
Closed 9 years ago.
I have a problem when i compile my perl program :
it mention :
Can't locate Bench.pm in #INC (#INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at test.pl line 4.
BEGIN failed--compilation aborted at test.pl line 4.
Any idea please?
Thanks
Install Bench as you would any other CPAN module, e.g. with cpanm, cpanp or cpan.
You might want to first use perlbrew to install a local (and newer) version of Perl so you won't be touching anything related to the system Perl installation.
First, check if you have installed Bench module:
%> perl -MBench -e 1
If you get the error message, you have to install it:
%> cpan Bench