Why does Perl say that it can't find my module? - perl

I wanted to play with XML::Rabbit, however I've got a problem even with the simplest code. I managed to strip this into one line.
In a simple file, I use
use Class::Load;
and then:
perl test_optlist.pl
Can't locate Data/OptList.pm in #INC (you may need to install the Data::OptList module) (#INC contains: [CUT]) at /home/szymon/perl5/lib/perl5/Class/Load.pm line 8.
BEGIN failed--compilation aborted at /home/szymon/perl5/lib/perl5/Class/Load.pm line 8.
Compilation failed in require at test_optlist.pl line 2.
BEGIN failed--compilation aborted at test_optlist.pl line 2.
so let's install it:
$ cpanm Data::OptList
Data::OptList is up to date. (0.107)
Perl version:
This is perl 5, version 17, subversion 8 (v5.17.8) built for x86_64-linux
Where is the problem?

You're surely using another perl's cpanm. Do
perlbrew install-cpanm
to install a version of cpanm under perlbrew's control, make sure this new cpanm is the one found first in the path (though I suspect it will be), then try again

Related

Bugzilla 5.0 install on OpenShift - Can't locate parent.pm in #INC

Attempting to install Bugzilla on an OpenShift small gear. Using SSH to wget 5.0 tarball, untar-ing and running the checksetup.pl --check-modules script gives me this error:
Can't locate parent.pm in #INC (INC contains: . lib /var/openshift/[app-id]/app-root
/runtime/repo/libs /var/lib/openshift/[app-id]/perl/perl5lib/lib/perl5 /usr/local/lib64
/perl5 /usr/local/share/perl5 /usr/lib/lib64/perl5/vendor-perl /usr/share/perl5/vendor-perl
/usr/lib64/perl5 usr/share/perl5) at Bugzilla/Constants.pm line 14.
BEGIN failed--compilation aborted at Bugzilla/Constants.pm line 14.
Compilation failed in require at ./checksetup.pl line 27.
BEGIN failed--compilation aborted at ./checksetup.pl line 27.
Line 14 of Bugzilla/Constants.pm: `use parent qw(Exporter);`
Line 27 of ./checksetup.pl: `use Bugzilla::Constants;`
[app-id] in the paths is just a random string of hex digits used to identify an OpenShift application.
All help would be greatly appreciated. Thanks in advance!
That means either parent is not installed in your system or it's not a part of #INC.
Try perldoc -l parent to see if it's installed or not.
If it's installed then update PERL5LIB enviroment variable to add path to directory where module is installed.
If it's not installed then run cpan parent to install.
Also see:
How do I 'use' a Perl module in a directory not in #INC?
How to change #INC to find Perl modules in non-standard locations
Apparantly OpenShift has a cpan.txt file in the .openshift folder. Adding parent to that folder installed the required module.
#please install above packages:
[root#rsync ~]# yum install perl-parent -y

Is version.pm available in CPAN any longer?

I am trying to find the Perl Module version.pm to fix the error below I am receiving while trying to install module CPAN-Meta-Requirements-2.133. But I don't see version.pm, the only one I see is Version.PM which is obviously not the one Perl is looking for. Can anyone point to where I can get this version or how I can fix this dependency if version.pm is no longer available?
Perl Version:
v5.16.3
OS:
GNU/Linux
x86_64 x86_64 x86_64
Error:
Can't locate version.pm in #INC (#INC contains: # Line breaks added
/root/CPAN-Meta-Requirements-2.133/blib/lib # for readability
/root/CPAN-Meta-Requirements-2.133/blib/arch
/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 (eval 1) line 2.
BEGIN failed--compilation aborted at (eval 1) line 2.
BEGIN failed--compilation aborted at /root/CPAN-Meta-Requirements-2.133/blib/lib/CPAN/Meta/Requirements.pm line 48.
Compilation failed in require at t/accepts.t line 4.
BEGIN failed--compilation aborted at t/accepts.t line 4.
t/accepts.t ............ Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
version has come with Perl since Perl 5.10, so it's weird that you would have to install it.
$ corelist version
version was first released with perl v5.9.0
But version is also available on CPAN in its own distribution in order to allow people to upgrade version without upgrading Perl.
So you may indeed install it as any other module.
cpan version
OK, so first: your link is to CPAN/Version.pm. This is very different than version.pm. Directory names and the path relative to Perl's include directory are very important to Perl, and putting a .pm file in the wrong location relative to the include path can break Perl pretty badly.
Second: because of that, never install Perl modules manually. Use cpanm instead:
curl -L https://cpanmin.us | perl - --sudo App::cpanminus # Omit --sudo if your perl isn't installed as root
cpanm version
Third: the version.pm that you want is this one: https://metacpan.org/pod/distribution/version/lib/version.pod, in the JPEACOCK/version-0.9912 distribution.

Installing cURL modules for Perl on Windows

I have ActivePerl 5.14.2 on my Windows machine. I have been trying to install the LWP cURL module. I have already installed the libcurl-dev library and GCC on my machine.
I also understand that LWP cURL has a dependency on the WWW-Curl-Easy module. So I installed that too. I installed all these through the command lines using the steps given in the Readme files. I ran the perl makefile.pl command followed by a make and a make install. No errors were given out during the installation.
I am trying to execute this sample code to test my LWP cURL installation:
use LWP::Curl;
use strict;
use warnings;
my $lwpcurl = LWP::Curl->new();
my $content = $lwpcurl->get('http://search.cpan.org','http://www.cpan.org');
I am receiving the below error:
Can't locate loadable object for module WWW::Curl in #INC (#INC
contains: C:/Perl64/site/lib C:/Perl64/lib .) at
C:/Perl64/site/lib/WWW/Curl.pm line 11. BEGIN failed--compilation
aborted at C:/Perl64/site/lib/WWW/Curl.pm line 11. Compilation failed
in require at C:/Perl64/site/lib/WWW/Curl/Easy.pm line 9. Compilation
failed in require at C:/Perl64/site/lib/LWP/Curl.pm line 5. BEGIN
failed--compilation aborted at C:/Perl64/site/lib/LWP/Curl.pm line 5.
Compilation failed in require at D:\Varsha\Curl.pl line 1. BEGIN
failed--compilation aborted at D:\Varsha\Curl.pl line 1.
Where am I going wrong?
This is probably not the direction you want to go, but I'd advise you to consider upgrading your perl and changing distributions:
Install Strawberry Perl - 5.18.2.2 is the currently recommended version.
Install cpanm: perl -MCPAN -e "install App::cpanminus"
Install LWP::Curl: cpanm LWP::Curl
I won't bother trying convince you of the change, but Strawberry Perl and cpanm in combination make installing modules a lot easier than having to dealing with the proprietary ppm's of ActivePerl in my opinion.
Just something to consider if you ever get tired of the occasional headaches.
The error means that WWW::Curl is either not installed or its path is not searchable (it's not in #INC). So the solutions are
Make sure that the module is installed.
Add the path where the module is installed to the #INC. Since you are on Windows, you can use set PERL5LIB = c:\path\to\dir
For a permanent solution follow the below:
Right-click My Computer and click Properties.
In the System Properties window, click on the Advanced tab.
In the Advanced section, click the Environment Variables button.
In the Environment Variables window in the "User variables for Foo Bar" section click on New and type in the following:
Variable name: PERL5LIB
Variable value: c:\path\to\dir
Then click OK 3 times. Windows that you open after this will already know about the new variable. Type this in the command window, to see the newly set value:
echo %PERL5LIB%
This will add the private /home/foobar/code directory (or c:\path\to\dir directory) to the beginning of #INC for every script that is executed in the same environment.
Also see: Installing perl dependency automatically in perl

Can not install Apache2::Const module

I have installed Apache 2.2.25 with mod_perl 2.0.7 running on Debian 7.1.0. During its installation mod_perl had to install module named Apache2::Const, but it didn't. mod_perl have installed modules from the same group, e.g. Apache2::Access, Apache2::Connection, Apache2::RequestUtil.
So when I use this command (i /Apache2::Const/) in cpan shell it outputs following:
cpan[3]> i /Apache2::Const/
Module id = Apache2::ConstantsTable
CPAN_USERID PHRED (Fred Moyer <fred#redhotpenguin.com>)
CPAN_VERSION undef
CPAN_FILE P/PH/PHRED/mod_perl-2.0.8.tar.gz
UPLOAD_DATE 2013-04-18
INST_FILE (not installed)
And when I use this command (install Apache2::Const):
cpan[4]> install Apache2::Const
Warning: Cannot install Apache2::Const, don't know what it is.
Try the command
i /Apache2::Const/
to find objects with matching identifiers.
I've tried to run:
install Apache2::ConstantsTable
But it didn't help.
Also, when I run following script:
perl -e "use v5.14.2; use Apache2::Const"
it outputs:
Not a CODE reference at /usr/lib/perl/5.14/DynaLoader.pm line 207.
END failed--call queue aborted at /usr/local/lib/perl/5.14.2/ModPerl/Const.pm line 207.
Compilation failed in require at /usr/local/lib/perl/5.14.2/Apache2/Const.pm line 18.
BEGIN failed--compilation aborted at /usr/local/lib/perl/5.14.2/Apache2/Const.pm line 18.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
I tried to install this module manually (via Makefile.PL) from mod_perl package. I also tried to reinstall mod_perl. Nothing helped.
All the other Apache2::* modules works correctly.
I really need to install Apache2::Const module. Thanks for your replies.
Solved long time ago by installing all this stuff from debian package. I was hard noob in linux when I posted the question.

Expect module not working in perl

I have installed expect module in perl at location C:\strawberry\perl\lib.
As a pre-requisite i have installed IO-Tty module first at same location were perl is installed.
Now if i am doing
use Expect;
It is throwing error
Can't locate IO/Pty.pm in #INC (#INC contains: C:/strawberry/perl/site/lib C:/st
rawberry/perl/vendor/lib C:/strawberry/perl/lib .) at C:/strawberry/perl/lib/Exp
ect.pm line 22.
BEGIN failed--compilation aborted at C:/strawberry/perl/lib/Expect.pm line 22.
Compilation failed in require at croak.txt line 1.
BEGIN failed--compilation aborted at croak.txt line 1.
Possible reasons are
Perl is looking for IO::Pty and IO::Tty module which are called from Expect.pm. But When i have installed IO::Tty module, it is having 2 pm files with names Pty.pm and Tty.pm
package Expect;
use IO::Pty 0.97; # We need make_slave_controlling_terminal()
use IO::Tty;
But perl is looking for IO::Tty module.
Is this causing the issue. If yes then how can i move forward
Expect does not work under Windows.
At least this is my impression when looking at CPAN Resters results. This table here:
http://matrix.cpantesters.org/?dist=Expect;maxver=1
shows that there was never a PASS for Expect under Windows.
Also, the Expect documentation talks about the module not working with ActivePerl and recommends to use cygwin instead:
https://metacpan.org/module/RGIERSIG/Expect-1.21/Expect.pod#Can-I-use-this-module-with-ActivePerl-on-Windows.
I assume that Expect does not work with StrawberryPerl, too.
Did you installed these modules using cpan? - I would highly recommend to install modules only via cpan, so you'll get all the dependencies needed.
If you've done so, try to reinstall it and watch out for any errors.
I tested the install via cpan and it needs to compile the IO::Tty package, so maybe you need to set-up an build environment for any perl modules you would like to install.
If you just copied some precompiled files verify that the files you're missing really exist and download the package again.
Edit:
What I missed - The full path for your Pty.pm and Tty.pm should be something like "C:/strawberry/perl/lib/IO/Tty.pm"