Openshift Perl dependencies not loading from .openshift/cpan.txt - perl

I have reviewed the dependency documentation found here:
https://help.openshift.com/hc/en-us/articles/202185484-Adding-dependencies-to-applications
And reviewed the information on .openshift/cpan.txt replacing deplist.txt found here:
https://developers.openshift.com/en/perl-overview.html#_template_repository_layout
I have attempted to use the following file in both locations
File::Slurp
File::Path
File::Basename
DBI
XML::Simple
Moose
However the build does not seem to recognize these dependencies. The build does not report errors, but the cpan modules are not available.
[myapp-mydomain.rhcloud.com]\> perl -e "use File::Slurp"
Can't locate File/Slurp.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 -e line 1.
BEGIN failed--compilation aborted at -e line 1.
This is a php application with mySql and phpMyAdmin cartridges but I have not found any way to add a "Perl Cartridge" and I saw a post (can't find the link) that indicated it was not necessary as perl was available with all apps. I think I'm missing something somewhere, maybe a Perl cartridge or configuration file is necessary, or maybe headers other content needed in the cpan.txt file? The documentation indicates that the cpan.txt file should "look something like this" - but I could not find anything that gave a real file format spec.
Thanks in advance for your help.

Since you are using the PHP cartridge, you will not be able to automatically install Perl modules using the above methods. That only works on the Perl cartridge. You can try sshing into your gear and running the "perl -MCPAN -e shell" manually, but you might not have write access to the ~/.cpan directory on your gear, so that may not work either. If you can provide more information about what you are trying to do someone might have a suggested solution.

Related

Perl mixed up, Cpan can not install

Hi I wanted to install a package via cpan, but I get the following error:
cpan[1]> install Log::Log4perl
Reading '/home/paulzierep/.cpan/Metadata'
Database was generated on Fri, 30 Sep 2016 06:29:02 GMT
Running install for module 'Log::Log4perl'
Checksum for /home/paulzierep/.cpan/sources/authors/id/M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz ok
Scanning cache /home/paulzierep/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Have /usr/lib/x86_64-linux-gnu/perl/5.22.1
Want /usr/lib/x86_64-linux-gnu/perl/5.22
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [5.22.1]
Config says: [x86_64-linux-gnu-thread-multi]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Generating a Unix-style Makefile
Writing Makefile for Log::Log4perl
Writing MYMETA.yml and MYMETA.json
MSCHILLI/Log-Log4perl-1.47.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz
make: *** No rule to make target '/usr/lib/x86_64-linux-gnu/perl/5.22/Config.pm', needed by 'Makefile'. Stop.
MSCHILLI/Log-Log4perl-1.47.tar.gz
/usr/bin/make -- NOT OK
Failed during this command:
MSCHILLI/Log-Log4perl-1.47.tar.gz : make NO
Well it says to check my perl installation, which is:
perl --version
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi
(with 58 registered patches, see perl -V for more detail)
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Here's #INC:
/usr/lib/x86_64-linux-gnu/perl/5.22.1/ /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
That what I get for:
paulzierep#naproxen:~$ perl -E 'say for #INC'
/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
.
paulzierep#naproxen:/home$ perl -MFile::Spec -E 'say for File::Spec->path'
/home/paulzierep/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
This typically happens when the perl you invoke looks in library directories that other perls left behind. Part of the error is:
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Start investigating there. Find out where it's finding the mismatched Config.pm and fix that issue. Running perl -V to see what's in #INC will help.
Beyond that you'll have to tell us a lot more about your setup.
You've previously mentioned adding a directory to PERL5LIB you shouldn't have added. Please reverse this change and this problem will go away.
You should really take another look at the comments on your previous question
Why does the default cpan on Ubuntu 16.04 give the error "Can't locate B.pm in #INC"?
where I observed that your #INCcontains your home directory /home/paulzierep in the last position
I asked whether the environment variables PERL5LIB or PERL5OPT were set, and your only response says
I changed the PERL5LIB environement var to usr/lib/x86_64-linux-gnu/perl/5.22.1/ and indeed I am able to open the cpan shell, but ones I try an install now, I get: Your perl and your Config.pm seem to have different ideas about the architecture they are running on
I don't know what you have done to get your home directory at the end of #INC. Both PERL5LIB and the -I command-line options use unshift instead of push, and add locations to the start of the #INC array
It's quite possible to build a new perl image with your home directory in #INC by default, but surely you would have said so if that is what you had done?
Let me be clear: PERL5LIB and PERL5OPT should be undefined for normal operation of perl
So after deleting the perl related environment variables I came back to my previous error post cpan command gives the error "Can't locate B.pm in #INC".
Which I managed to solve, so I assume this answers this post then as well.

Perl Compilation Error: "Can't locate local/lib.pm"

As a Perl rookie, I have made a rookie mistake.
I was working on a project that required an HTML parser so I thought I'd install Perl's HTML::TreeBuilder::XPath module, so I dove into cpan and perlbrew without a full understanding of how they work. I created a local library, but would like to return everything back to default. However, I get this error every time I open a terminal window (twice, for some reason):
Can't locate local/lib.pm in #INC (#INC contains:
/Users/James/perl5/lib/perl5
/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 .).
BEGIN failed--compilation aborted.
I've seen the similar StackOverflow question here but I do not have apt-get installed.
How can I reset my machine so that this error no longer appears and it uses the default library?
The local::lib installation instructions tell you to add a line to your .bashrc or .bash_profile. From your error, it looks like the line
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
is still present. Look for it and remove it.
For me this meant I had an earlier aborted run of cpan's installation.
fix: remove ~/.cpan and ~/perl5 dirs, and remove anything about them from .bashrc, and do it again...

Can't locate Moo.pm in #INC

I am trying to run a .pm program in dzsoft perl editor. but i got this error
Can't locate Moo.pm in #INC (#INC contains: C:\Users\123\Desktop\ C:/Perl64/site/lib C:/Perl64/lib .) at UniNE.pm line 5.
My interpertor is ActivePerl-5.18.2.1802-MSWin32-x64-298023
how can I add moo.pm to lib?
This error means you've got a line that says use Moo; and it can't find it. The first question is - have you installed 'Moo'? If not, then:
perl -MCPAN -e shell
install Moo
This may take a bit of faffing with ActivePerl, so you may want to try and use ppm instead. If you do definitely have it installed, then I would suggest the next port of call is to try and figure out where it ended up - search for Moo.pm in your local filesystem, and compare that against your #INC path. You may find permissions are the root cause, and it's unreadable by your perl user.
I should install Moo module first. Try from cmd-line: cpan Moo

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"

Using XPath with Perl

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.