I am trying to create a sample web service using Dancer. I am using Ubuntu 10.04 as my OS. I installed Dancer and dependencies using CPAN client and can also do
dancer -a MyApp
However, when I try to run the app.pl file, the code throws an error saying YAML.pm not found. I am sure this file was downloaded when the dependencies were installed. A have a few questions :-
1. Where does CPAN put all these files which were downloaded? How are they included in the #INC?
2. For using Dancer, do I have to manually include all the files in #INC?
I tried to create a very simple perl dancer app the says hello world by including the Dancer.pm path in #INC. However, it keeps failing because of some or the other dependency missing.
Help me in understanding what am I doing wrong?
cpan should put files in one of the path from #INC
perl -E '$"="\n"; say "#INC"'
Output on my system:
/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
.
And cpan puts files in /usr/local/share/perl/5.14.2
Because this path exists in #INC you shouldn't include it manually. And what about Dancer, YAML is not hard dependency for it, because of this it wasn't installed.
Related
I just set up an Ubuntu 16.04 box and am trying to get some Perl modules installed. I launched CPAN, and it went through the automatic config procedure. At the end it dumped a few questionable messages:
Couldn't untar local-lib-2.000019.tar: 'Cannot allocate memory'
'YAML' not installed, will not store persistent state
HAARG/local-lib-2.000019.tar.gz
Had problems unarchiving. Please build manually
Can't locate local/lib.pm in #INC (you may need to install the local::lib module) (#INC contains: /home/steve/perl5/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base /home/steve/waternow) at /usr/share/perl/5.22/CPAN/FirstTime.pm line 1347.
When I restarted it, it came up with the CPAN shell command line like nothing is wrong. Did it get configured correctly, or is there something else I need to do? I'm not a Lunix noob but not an expert either.
Also are there any better options for installing Perl modules on Ubuntu besides CPAN (for example like Activestate Perl Package Manager on Windows)? I've never been too fond of CPAN because of experiences like this.
I am trying to run a topology generation tool (http://informatique.umons.ac.be/networks/igen/) on linux where I need to install plenty of modules of perl.
For now, I have already installed CPAN. This tool requires a Statistics::Basic module which I also installed successfully.
However, after installing this module, the tool requires a package in this Statistics::Basic module. Here are the hints appeared in the command line:
Can't locate Statistics/Basic/CoVariance.pm in #INC (you may need to install the Statistics::Basic::CoVariance module) (#INC contains: /usr/local/share/perl/5.18.2/ /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 .)
I get confused on this request since it is already included in the Statistics::Basic module. Even though I tried to install it independently, the cpan responded this:
cpan[1]> install Statistics::Basic::CoVariance
Warning: Cannot install Statistics::Basic::CoVariance, don't know what it is.
Does anyone know how to fix it? I am new to perl so I don't know how to make it work. Thx.
You need to replace the capital V with a small v in a couple of files and you need also some other modifications. You can find here a guide on how to make IGen-0.15 work again.
I follow the book "The Definitive Guide to Catalyst". Now when I run the command "script/lolcatalyst_lite_create.pl view Web TT", I get as follows
exists "/home/hengaini/LolCatalyst-Lite/script/../lib/LolCatalyst/Lite/View"
exists "/home/hengaini/LolCatalyst-Lite/script/../t"
Couldn't load helper "Catalyst::Helper::View::TT", "Can't locate Catalyst/Helper/View/TT.pm >in #INC (#INC contains: /home/hengaini/LolCatalyst-Lite/script/../lib /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 (eval 338) line 2.
question:
1.Is Catalyst still popular? Every web framework says good;
2.How to solve above problem?
Thanks!
1 - Yes, at least with me :-)
Catalyst is well maintianed. There is no new Perl framework aimed at replacing Catalyst.
2 - Install the missing module:
sudo cpan Catalyst::Helper::View::TT
Make sure everything is installed
sudo cpan Catalyst::Runtime
sudo cpan Catalyst::Devel
Yes, Catalyst is quite popular, and has a very active community behind it.
But the issue you've run into there isn't Catalyst specific. It looks like Catalyst::Helper::View::TT isn't installed on your server.
Try installing it from CPAN and see how you go. You'll also need to install Template (Template Toolkit) if you haven't already.
(If you've gotten as far as you have, I guess you know how to install from CPAN!)
I am trying to replicate what my C#/XPath code does on Linux using Perl. I copied and pasted the code in Example 8-6 in Perl & XML. If I understand right, I should be able to run that Perl code, put this code in terminal
xmlPerl.pl mydatafile.xml "/inventory/category/item/name"
But when I try to run the Perl file, it doesn't work. Here is the error:
[root#Perl ~]# perl xmlPerl.pl
Can't locate XML/XPath.pm in #INC (#INC contains: /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 xmlPerl.pl line 3.
BEGIN failed--compilation aborted at xmlPerl.pl line 3.
What am I doing wrong? I think it has something to do with the XML and XPath names in the beginning of my code. Do I need to install something to use the XPath framework? I am running on RedHat 5.5.
From perldiag:
Can't locate %s
You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in #INC, unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is, or maybe the script needs to add the library name to #INC. Or maybe you just misspelled the name of the file. See require in perlfunc and lib.
You don't have installed XML::XPath module, or Perl not found it. Install module with CPAN:
> cpan XML::XPath
or with package manager:
> apt-get install libxml-xpath-perl
Or if it already installed say where it is with PERL5LIB environment variable:
> PERL5LIB=/path/to/lib perl ...
#INC variable:
BEGIN {
unshift(#INC, '/path/to/lib');
}
or lib pragma:
use lib '/path/to/lib';
That's the standard error that comes from trying to use a module that isn't installed. You should install it.
Ideally use the OS package for it; for example on a debian-derived OS (such as Debian or Ubuntu)
$ apt-get install libxml-xpath-perl
Failing that, you can install it as usual using CPAN
$ cpan XML::XPath
The answer is in the first part of your error:
Can't locate XML/XPath.pm
In Perl, the huge benefit is from using modules, or libraries, that others have written for you and you can reuse. In this case, someone has written a module called XML::XPath (in Perl, the path is delineated by '::') and you just need to install it. The easiest way to install it is via cpan, it's a tool that comes installed with most Perl installations. Just run:
cpan
(you'll be dropped into a different command prompt)
install XML::XPath
This will go out and fetch XML::XPath, unpack it, generate the Makefile, check for dependencies (and install any that are missing), make it, test it, and install it for you. Look here for more information on using CPAN.
I'm trying to add an check_esx3.pl script to my icinga. But trying to execute the script
./check_esx3.pl
Gives me the following error:
Can't locate Nagios/Plugin.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 ./check_esx3.pl line 31. BEGIN
failed--compilation aborted at ./check_esx3.pl line 31.
I've been looking around and googling, but I've not been able to find any solution.
You need to install the Nagios::Plugin Perl module.
When you build the Nagios Plugins package from https://www.nagios-plugins.org, one of the configure options is --enable-perl-modules. It will build the Nagios::Plugin:* modules (since it has several modules included that need them), and install them to your system Perl library directory when you run 'make install' as root.
You can also go directly to the source and install the modules from CPAN, by running the command cpan Nagios::Plugins from the command line, also as root. You could possibly run these as the icinga or nagios user, but there's no guarantee they'll get installed into the proper places unless you've done some work beforehand to define PERL5LIB (which is way out of the scope of this answer) and done a bit of hackery in your startup scripts that define a special PERL5LIB for the icinga/nagios process on startup.