Error: Can't locate File/HomeDir.pm in #INC - perl

I use a Mac OS X 10.8, and want to run the latexindent.pl perl script on my latex files. This script is made by https://github.com/cmhughes/latexindent.plx. When I run this script on a latexfile I get this error message:
Can't locate File/HomeDir.pm in #INC (#INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4/darwin-thread-multi-2level /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at helloworld.pl line 10.
BEGIN failed--compilation aborted at helloworld.pl line 10.
It seems that I am missing the File::HomeDir module in perl so I tried to download it using:
sudo perl -MCPAN -e 'install File::HomeDir',
I get the following error:
Can't locate object method "install" via package "File::HomeDir".
I managed to install the YAML::Tiny package without any problems.
I tried to run:
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use FindBin;
6 use YAML::Tiny;
7 use File::Copy;
8 use File::Basename;
9 use Getopt::Std;
10 use File::HomeDir;
11
12 print "hello world";
13 exit;
and got the same Error message as above...
Do anyone know what to do?

sudo perl -MCPAN -e 'install "File::HomeDir"'
^ ^

I had a similar problem. I just ran these commends, and it worked for me
sudo cpan -i File::HomeDir
then
sudo cpan -i Unicode::GCString
Basically, I will run latexindent file_name.tex, then an error message will appear that says you may need to install the XXXX module then I install the XXXX module using sudo cpan -i XXXX

Related

perl module not found: still missing a file Telnet.pm after adding it to the path

I'm getting the following error while trying to conect via
use FileHandle;
use IPC::Open2;
$p=open2(\*R,\*W,"cr");
$username = "m"; # your login HERE
$passwd = "s"; # your PASSWORD here
use Net::Telnet ();
$telnet = new Net::Telnet (Timeout => 4000,
Prompt => '/c% /',
Port => 2000 );
I have created the directory Net/Telnet.pm in my #INC but it didn't helped.
What should I fix yet ?
$ perl tm8.pl
Can't locate Net/Telnet.pm in #INC (you may need to install the Net::Telnet module) (#INC contains: /usr/local/lib/perl5/site_perl/5.30/x86_64-cygwin-threads /usr/local/share/perl5/site_perl/5.30 /usr/lib/perl5/vendor_perl/5.30/x86_64-cygwin-threads /usr/share/perl5/vendor_perl/5.30 /usr/lib/perl5/5.30/x86_64-cygwin-threads /usr/share/perl5/5.30) at tm8.pl line 8.
BEGIN failed--compilation aborted at tm8.pl line 8.
I will assume that you already try install the Net::Telnet with cpanm Net::Telnet or
perl -MCPAN -e shell
install Net::Telnet
I suggest for you try install the Net::Telnet with sudo command:
sudo perl -MCPAN -e shell
install Net::Telnet

Perl Compiling PP issue in Strawberry Perl [duplicate]

I've been using pp
https://metacpan.org/pod/pp
A while ago!
However when hiring another hosting, when I run the pp command the scripts do not run on the server
CentOS Linux release 7.9.2009 (Core)
Perl v 5.32.1
Command using pp, host old
$ pp -x -c name.pl
When running
./a.out
Unable to open html entities file (/tmp/par-726f6f74/cache-78cdefedff4d2afddea0035addc3b570c8f0bfd5/inc/lib/Mojo/resources/html_entities.txt): No such file or directory at script / name.pl line 13.
Compilation failed in require at script / name.pl line 13.
BEGIN failed - compilation aborted at script / name.pl line 13.
And when I run ./name.pl it runs normally.
Any suggestion?
name.pl
#!/usr/bin/perl
use FindBin qw($Bin);
use lib ("$Bin");
use DBI;
use Number::Format;
use Encode qw(decode encode);
use File::Basename;
use Mojo::Util qw(b64_encode b64_decode url_escape url_unescape);
use Mojo::JSON qw(decode_json encode_json);
use Image::ExifTool;
use LWP;
print "Test Mojo";
This same command works normally in version 5.28 on another server/hosting
You need to add the file html_entities.txt to the archive.
The following seems to work for me:
Find the location of the file:
$ perl -MMojo::Util -MFile::Basename=dirname -E '$fn = (dirname $INC{"Mojo/Util.pm"}) . "/resources/html_entities.txt"; say $fn'
/home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Mojo/resources/html_entities.txt
Copy the file to a local directory:
$ mkdir -p ./lib/Mojo/resources/
$ cp /home/hakon/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/Mojo/resources/html_entities.txt ./lib/Mojo/resources/
Add the file to the archive
$ pp -x -c -a lib/Mojo/resources/html_entities.txt name.pl

unavailable cpan in cygwin

I have unsuccessfully tried to install Perl module in cygwin like in an answer. I have got the following error:
$ perl -MCPAN -e shell
Can't locate CPAN.pm in #INC (you may need to install the CPAN module) (#INC contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-threads /usr/lib/perl5/5.22 .).
BEGIN failed--compilation aborted.
How can I obtain cpan in my cygwin?
There are some additional details. Actually my purpose was to install ack like in answer. However, it didn't work. After installing I have got an error:
$ ack
Can't locate filetest.pm in #INC (you may need to install the filetest module) (#INC contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-threads /usr/lib/perl5/5.22 .) at /home/loom/bin/ack line 218.
BEGIN failed--compilation aborted at /home/loom/bin/ack line 218.
The following was my trying to locate cpan
$ cpan
-bash: cpan: command not found
$ ll /usr/lib/perl5/5.22/CPAN.pm
ls: cannot access '/usr/lib/perl5/5.22/CPAN.pm': No such file or directory
$ find /usr/ -name *.pm | grep CPAN
/usr/lib/perl5/5.22/CPAN/Meta/Converter.pm
/usr/lib/perl5/5.22/CPAN/Meta/Feature.pm
/usr/lib/perl5/5.22/CPAN/Meta/History.pm
/usr/lib/perl5/5.22/CPAN/Meta/Merge.pm
/usr/lib/perl5/5.22/CPAN/Meta/Prereqs.pm
/usr/lib/perl5/5.22/CPAN/Meta/Requirements.pm
/usr/lib/perl5/5.22/CPAN/Meta/Spec.pm
/usr/lib/perl5/5.22/CPAN/Meta/Validator.pm
/usr/lib/perl5/5.22/CPAN/Meta/YAML.pm
/usr/lib/perl5/5.22/CPAN/Meta.pm
/usr/lib/perl5/5.22/Parse/CPAN/Meta.pm
Reinstalling perl helped.
$ apt-cyg install perl

How to update perl module with cpanm

I try to install/update Perl module with cpanm. But, it failed for every modules.
for example:
cpanm Config::General
--> Working on Config::General
Fetching http://www.cpan.org/authors/id/T/TL/TLINDEN/Config-General-2.56.tar.gz ... OK
Configuring Config-General-2.56 ... OK
Building and testing Config-General-2.56 ... OK
Successfully installed Config-General-2.56 (upgraded from 2.52)
1 distribution installed
So, i expect that version of Config::General is now 2.56, but... :
perl -e 'use Config::General 2.56'
Config::General version 2.56 required--this is only version 2.52 at -e line 1.
I try the same logged in superU but same problem...
But now, i have Perl lib in
~/perl5/lib/perl5/ and /usr/lib/perl/5.18/
How can i properly update Perl modules with cpanm?
Some information about my install:
$ perl -E'
say "$_=$ENV{$_}" for qw( PERL_MM_OPT PERL_MB_OPT PERL5LIB );
say "--";
say for #INC;
'
PERL_MM_OPT=INSTALL_BASE=/home/hacklionex/perl5
PERL_MB_OPT=--install_base "/home/hacklionex/perl5"
PERL5LIB=
--
/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
.
Your are instructing the module installers to install modules in /home/hacklionex/perl5 (via PERL_MM_OPT and PERL_MB_OPT), but you don't tell Perl to look for modules there (it's not in #INC). Add the following to your login script:
export PERL5LIB=/home/hacklionex/perl5/lib/perl5
Or add the following to your script:
use lib '/home/hacklionex/perl5/lib/perl5';

Can't locate Email/Sender/simple.pm

I want to send an email using perl Email module. I have installed Email::Sender. After running the following
sudo perl -MCPAN -e shell
install Email::Sender
and it says Email::Sender is up to date.
But when I run my script I get the following error:
Can't locate Email/Sender/simple.pm in #INC (#INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /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/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at ./first.pl line 8.
BEGIN failed--compilation aborted at ./first.pl line 8.
Script:
use Email::Sender::simple qw(sendmail); #line 8
use Email::Simple; #line 9
Any help appreciated.
The module is called Email::Sender::Simple (with two capital S characters), not Email::Sender::simple
Although in perl-CPANEL shows the library installed correctly, it doesn't work, you can try next:
1) install epel repository from rpm (you can find it easy, by searching on google)
2) issue yum repolist
3) issue yum install perl-Mail-Sender.noarch