I want to created perl modules in intellij derived by Tests. I created following test in a new project as shown below
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
done_testing();
But when i am trying to run the test (Shift+Alt+F10), it fails with below error
Testing started at 10:51 ...
C:/Strawberry/perl/bin\perl.exe C:/Strawberry/perl/bin/prove.bat -PPassEnv --formatter TAP::Formatter::Camelcade --merge --recurse --jobs 1 D:/workspace/code/repo/Modules/ImageUtilities/ReaConverterTest.t
Can't load module PassEnv at C:/Strawberry/perl/bin/prove.bat line 26.
Process finished with exit code 2
But when I run the test from the command line it works fine
$ perl -w ReaConverterTest.t
1..0
I see that there was an issue reported with intellij perl plugin(https://github.com/Camelcade/Perl5-IDEA/issues/1966) but it is closed. Looks like it was fixed in 2019.1 Perl but I am clueless why it's failing for me.
Any idea on how to fix this?
PS: I am using Git-Bash to run Perl scripts, IntelliJ using strawberry Perl installation on windows as Perl interpreter.
Update
When i run the script by adding "use PassEnv" it fails as there is no such module Searching from intellij also results in "no such module"
perl -w ReaConverter.t
Can't locate PassEnv.pm in #INC (you may need to install the PassEnv module) (#INC contain
s: /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/sha
re/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at ReaConverter.
t line 6.
BEGIN failed--compilation aborted at ReaConverter.t line 6.
Because of the -PPassEnv option used, prove attempts to load App::Prove::Plugin::PassEnv. It hasn't been installed. Simply install the module.
Note: You want to install it using Strawberry Perl, so the following appears to be the appropriate command from your preferred shell:
/c/Strawberry/perl/bin/cpanm App::Prove::Plugin::PassEnv
Related
When we install module this module can ship executable which is installed into local/bin directory.
if we spy into installed script we can notice that perl version is hardcoded:
/home/user/t/local/bin/mojo
#!/home/user/perl5/perlbrew/perls/perl-5.35.1/bin/perl5.35.1
Why perl version is hard coded?
I expect it should be /usr/bin/env perl:
$ which cpanm
/home/user/perl5/perlbrew/bin/cpanm
$ cat $(which cpanm) | less
#!/usr/bin/env perl
I expect it should be /usr/bin/env perl:
In this case it would take the Perl installation currently in the path. This might be a different Perl installation compared to what was used to install the application modules. In this case running the application might fail due to missing modules. Or it might show strange behavior since the installed modules have a different version than expected by application and thus can show different behavior.
For example imagine the case when there are two perl installations at your system. And when you install script with first perl you you can not run it with second perl, because second perl lacks modules available from first one.
It should have the path of the Perl with which it was installed.
This is the perl for which its dependencies has been installed.
This is the perl with which it has been tested.
If the script was made to rely on the environment as you suggest, it could pick up a different perl, and that would very likely cause it to fail.
For example, let's take a tool which has a shebang line of
#!/home/ikegami/usr/perlbrew/perls/5.34.0t/bin/perl -w
Regardless of the environment, it works fine.
$ /home/ikegami/usr/perlbrew/perls/latest/bin/tpage \
--define USER=World \
<<<'Hello, [% USER %]!'
Hello, World!
Now let's simulate the following shebang line:
#!/usr/bin/env perl -w
It fails misearbly despite the tool being correctly installed.
$ /usr/bin/env perl -w /home/ikegami/usr/perlbrew/perls/latest/bin/tpage \
--define USER=World \
<<<'Hello, [% USER %]!'
Can't locate Template.pm in #INC (you may need to install the Template module) (#INC contains: /home/ikegami/usr/perlbrew/perls/5.28.2t/lib/site_perl/5.28.2/x86_64-linux-thread-multi /home/ikegami/usr/perlbrew/perls/5.28.2t/lib/site_perl/5.28.2 /home/ikegami/usr/perlbrew/perls/5.28.2t/lib/5.28.2/x86_64-linux-thread-multi /home/ikegami/usr/perlbrew/perls/5.28.2t/lib/5.28.2) at /home/ikegami/usr/perlbrew/perls/latest/bin/tpage line 27.
BEGIN failed--compilation aborted at /home/ikegami/usr/perlbrew/perls/latest/bin/tpage line 27.
This is an unreliable solution subject to effects at a distance. For the same reason we scope variables, we should avoid env.
The story is different for self-contained scripts, but a self-contained script wouldn't be installed using ExtUtils::MakeMaker or Module::Build (the modules setting the shebang line), so such scripts aren't relevant here.
Seems correct question to my problem was: How to prevent perl from hard coding its version at shebang?
TLDR;
export PERL_MM_SHEBANG=relocatable
After reading article #Håkon Hægland adviced and reading #38
Now I see that there is two scenario:
when script is installed into system
when script is installed into application local/bin directory.
My case is second.
So for this case I should simultaneously set environment variable PERL_MM_SHEBANG to relocatable when I set current perl into path
This env variable implemented here
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
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.
I have a problem with the Tkx package. I use Perl 5.14.2 on CentOS, and I know that this version of Perl basically contains the Tkx package. When I try to get the version of Tkx (with the following code snipet)
perl -MTkx -e 'print Tkx::info("patchlevel");'
And I get the following error message:
couldn't load file "/tmp/tclpWVq4S": libXss.so.1: cannot open shared object file:
No such file or directory at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.
I searched for a sollution but I didn't find answer for it. Can anyone tell me what's going on here?
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What's the easiest way to install a missing Perl module?
I'm attempting to run a Perl script to convert SCXML to Graphviz DOT. I modified the first line of the script to:
#!/usr/bin/env perl
and chmod +x the file. When I run it via ./scmxl2dot.pl I see the following error output:
Can't locate LWP/Simple.pm in #INC (#INC contains: /opt/local/lib/perl5/site_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/site_perl/5.12.3 /opt/local/lib/perl5/vendor_perl/5.12.3/darwin-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.3 /opt/local/lib/perl5/5.12.3/darwin-multi-2level /opt/local/lib/perl5/5.12.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl .) at ./scmxml2dot.pl line 14.
BEGIN failed--compilation aborted at ./scmxml2dot.pl line 14.
Line 14 of the file is use LWP::Simple;
How do I:
Find out if I have this thing (module?) installed, and/or
Get LWP::Simple and make it available to the script?
This is running under OS X 10.7.3 and Perl 5.12.3 (as seen in the error).
You're already determined that you don't have it (somewhere it can be found).
perl -MCPAN -e'install "LWP::Simple"'
Execute the following from the command line:
perl -MLWP::Simple -e 1
If you don't get any output from the above command then the module is installed; if you get an error, it's not installed
to install use
perl -MCPAN -e'install "LWP::Simple"'
When perl encounters use My::Module it goes over the elements of the built-in #INC module that contains directory names. In each directory it check if there is a subdirectory called "My" and if in that subdirectory there is a file called "Module.pm".
check where LWP::Simple module is installed on your system and type below line just above the use LWP::Simple statement of your code.
use lib '/usr/local/module';
use LWP::Simple;
Take a look at the Perldoc webpage. This will tell you which modules are standard Perl modules and which ones aren't.
You can also use the perldoc command to find out if a Perl module is installed, and if it is, its documentation.
$ perldoc LWP::Simple
(If Perldoc doesn't execute as a command do ls -l /usr/bin/perl*. On Macs, some of the Perl commands don't have the execute bit turned on. To turn it on, do sudo chmod a+x /usr/bin/perl).
It just happens the LWP::Simple isn't a standard Perl module, and if you don't have it, you'll have to install it. Most people have already told you about cpan. Unfortunately, by default, the Mac doesn't have the needed command line development tools installed. You'll have to install them.
Once they're installed, you can use the cpan command to install LWP::Simple:
$ sudo cpan #Run cpan and configure it. It takes about 3 minutes
cpan> install LWP::Simple
cpan> exit