Cant install Net::SSH2 perl module - linux

I'm trying to install a perl module: Net::SSH2 with cpan but doesn't actually works.
cpan -f install Net::SSH2
Output:
CPAN: Storable loaded ok (v2.20) Going to read
'/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Mon, 22 May 2017 22:29:03 GMT HTTP::Date
not available ............. New CPAN.pm version (v2.16) available.
[Currently running version is v1.9402] You might want to try
install CPAN
reload cpan to both upgrade CPAN.pm and run the new version without leaving the current session.
...............................................................DONE
Going to read '/root/.cpan/sources/modules/03modlist.data.gz' Can't
locate object method "data" via package "CPAN::Modulelist" (perhaps
you forgot to load "CPAN::Modulelist"?) at (eval 16) line 1. at
/usr/share/perl5/CPAN/Index.pm line 518
CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at
/usr/share/perl5/CPAN/Index.pm line 85
CPAN::Index::reload('CPAN::Index') called at /usr/share/perl5/CPAN.pm line 955
CPAN::exists('CPAN=HASH(0x21fd2f0)', 'CPAN::Module', 'install') called at /usr/share/perl5/CPAN/Shell.pm line 1243
CPAN::Shell::expandany('CPAN::Shell', 'install') called at /usr/share/perl5/CPAN/Shell.pm line 1639
CPAN::Shell::rematein('CPAN::Shell', 'force', 'install', 'install') called at /usr/share/perl5/CPAN/Shell.pm line 1935
CPAN::Shell::ANON('CPAN::Shell', 'install', 'install') called at /usr/bin/cpan line 318
main::_default('ARRAY(0x1938f18)') called at /usr/bin/cpan line 278

It seems that your installation of CPAN is incomplete or otherwise corrupted. OS and Perl version could be helpful. On many current Linux distributions, Perl modules and their dependencies can be installed using the normal system software utilities like yum (RHEL/CentOS), apt (Debian/Ubuntu) and yast (SuSE). Drawback is that versions may not be the most current.

This PerlMonks thread has someone else with a similar problem. It looks like this answer worked in that case:
It looks to me like you have some corrupt data in your .cpan directory. I'd blow it away and try again:
$ rm -rf /home/user/.cpan
Try it at your own risk. In your case, you would need to delete /root/.cpan.
In addition, the correct use of cpan is to list the module names after the command. So, instead of cpan install Net::SSH2, you should use cpan Net::SSH2. If you use the -f option, you must specify -i: cpan -f -i Net::SSH2, but try without forcing things first. You do not want to willy-nilly install broken modules in the system's perl.
In fact, in general, you do not want to mess with the system's perl at all. Build your own perl and mess with it as much as you want.
PS: install is a dummy module created precisely because many people make this mistake.

The safest and most convenient way to install Perl modules can depend on distribution. For example, the recommended method on Fedora is:
$ sudo dnf install 'perl(Net::SSH2)'
As shown in that example, installing Perl modules on your system usually requires sudo or the root user. So you might want to try your command with sudo if you're a sudoer.
If you don't have that kind of power, you may need to install it locally. That usually means downloading it to a Perl library directory you create in your home directory, and including the path in #INC somehow, such as updating your $PERL5LIB to include the /home/user/perl/modules/Net-SSH2/lib/ or whatever your path to the module lib directory is.

Related

Remove perl package completely

I am trying to uninstall the old perl package and install a new package. I used rpm -e to uninstall the old package. I could still see the below files after uninstalling. How can i completely remove the perl package from my server. It runs on OEL 6.10. And when I do "perl -v" , I could see 5.30 version as output, even after uninstalling perl.
/opt/CWx/perl
/opt/CWx/modules/installed/Module-Build-0.4005/inc/Perl
/opt/CWx/modules/installed/Perl-OSType-1.003/blib/lib/Perl
/opt/CWx/modules/installed/Perl-OSType-1.003/blib/lib/auto/Perl
/opt/CWx/modules/installed/Perl-OSType-1.003/blib/arch/auto/Perl
/opt/CWx/modules/installed/Perl-OSType-1.003/lib/Perl
/opt/CWx/modules/Module-Build-0.4208/inc/Perl
/usr/src/kernels/2.6.32-754.11.1.el6.x86_64/tools/perf/scripts/perl
/usr/src/kernels/2.6.32-754.6.3.el6.x86_64/tools/perf/scripts/perl
/usr/src/kernels/2.6.32-754.2.1.el6.x86_64/tools/perf/scripts/perl
/usr/local/share/perl5_old/Perl
/usr/local/bin/perl
If you want to know which package installed a file you can use the command:
rpm -q --whatprovides [filename]
For example, for the first file in your list:
rpm -q --whatprovides /opt/CWx/perl
None of the files you list are in locations which are used by the standard Perl RPM on a RedHat-based system. You will, I expect, find that they are either installed by a completely different package or not installed by a package at all.
And that will also explain why you can still access Perl. Those files include other versions of the Perl compiler and I bet that whoever installed them also changed the PATH so that you have access to at least one of them.
If you want to know which Perl installation is responding to your commands, just run this:
which perl

How to specify which version of perl to use for a script without installing perlbrew

I have a script that must be run in Perl 5.10.1, although my university's linux cluster system uses the most recent version of Perl. I tried to install Perlbrew, but I don't think it worked.
I'm not sure how to specify the perl version in the shebang because of how I call/run this script. There is "cluster.pl", which is run by running "./command.txt".
Also, I don't think I can install Perlbrew because it's the university's linux system: After copy-pasting the installation commands, my terminal screen said the perlbrew patch was installed, but when I used "perlbrew install perl-5.10.1", it would say "command perlbrew not found" I don't know how to run the script
As of now, cluster.pl has this shebang:
#!/usr/bin/perl
One related question said to write this in the command line
/program/perl_v5.6.1/bin/perl scriptName.pl
#OP needed to use version 5.6.1, unlike me (I need 5.10.1)
However, I don't know whether "program" is OP's directory or a mandatory part of the path
Below is command.txt, which has the necessary input arguments:
#this is command.txt
./cluster.pl Datachr1 2 galGal5.Chroinfo.txt
Essentially, where would the suggested shebang go? Would I include "program" in my path too?
If you wrap your script in Perl's packaging framework, this is handled for you automatically. When it installs scripts, it changes the shebang line with the actual perl. You end up with something like this at the top of the file:
#!/usr/local/perls/perl-5.30.0/bin/perl
eval 'exec /usr/local/perls/perl-5.30.0/bin/perl -S $0 ${1+"$#"}'
if $running_under_some_shell;
#!/usr/local/bin/perl
You might try this with my app-rhich distribution. Download the tarball and run the Makefile.PL with the perl you want. Run make and it builds stuff into the blib staging directory. You should see the modified shebang there:
$ /Users/brian/bin/perls/perl5.30.0 MAkefile.PL
Checking if your kit is complete...
Looks good
WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod as part of this distribution. It is recommended to avoid using this path in CPAN modules.
Generating a Unix-style Makefile
Writing Makefile for App::rhich
Writing MYMETA.yml and MYMETA.json
$ make build
make: *** No rule to make target `build'. Stop.
$ make
cp lib/App/rhich.pm blib/lib/App/rhich.pm
cp script/rhich blib/script/rhich
"/usr/local/perls/perl-5.30.0/bin/perl" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/rhich
Manifying 1 pod document
Manifying 1 pod document
brian#otter app-rhich (master)[3125]
$ more blib/script/
#!/usr/local/perls/perl-5.30.0/bin/perl
package rhich;
use strict;
use warnings;
However, if your path to perl is a symlink to some other perl, this can get confused. I don't use perlbrew because I don't think it adds much other than saving you looking up a download URL. I install multiple perls (and How should I install more than one version of Perl?) and can use paths to them so I know which version using. There's a similar problem with env depending on how you set up your path. How you handle that is based on how you decide to manage things, but it's these sorts of questions that show that the tools of convenience aren't really that convenient.

A mess with different Perl installs

I tried to upgrade Perl and put my computer into a complete mess
I am currently running RHEL6.5, 64bits, and this is the thing:
I had perl-5.10.1 installed, and working nice. this came installed,
and I could see it from yum
I wanted to install Padre, an Perl IDE, but that required at least v5.11 [I was so close! :( ]
There were no newer version for Perl in the repos that I have access to (and I have a limitation that I can't add new repos)
I got approval from my boss to download perl-5.20 .0 from www.perl.org and tried to install it
... and the mess begins!
First I installed the new perl with my own id, and that pushed perl to somewhere under my home dir
I tested with 'perl -v' and could see that my env was pointing to the newer install, however, yum never recognized it (not really a problem)
When I tried to install Padre, seems somehow it had the hardcoded the original perl (from /usr/bin) and still claiming for something as newer as 5.11.
Trying to fix it, I did installed the new perl again, now using root, to make it push perl under /usr tree ... it installed, but pushed perl to /usr/local/bin, instead of /usr/bin
So again, I had one more perl install but Padre still looking for the one on /usr/bin
I give up about Padre, and deleted the files related to it, as well as the perl installed on my home dir, however a couple of perl scripts that I had already coded now are throwing errors like:
perl -cw "xmltest.pl" (in directory: /home/myid/scripts/xmltest.pl)
perl: symbol lookup error: /usr/lib64/perl5/auto/Data/Dumper/Dumper.so: undefined symbol: Perl_Istack_sp_ptr
Compilation failed.
... and Data::Dumper in not the only one ... every time I disable one of the modules, another one hangs in the same, or similar way
From what I read about this, seems that this issue is related to modules that were originally installed for one perl version, and are being called by another, however, I already forced the modules that I use to be reinstalled directly from CPAN, and they still failing
Question: How can I, safely, get free from this current perl installs, and perform a new clean install be able to use it w/o these versions conflicts?
My major concern are about the numerous apps that I have that depends on Perl, and I my not broke then on a uninstall
Any help will be much appreciate.
You should:
cleanup
clean (comment out) your ~/.profile from any unwanted paths, and so on
clean any new perl installation from your $HOME (move to safe place for sure)
in short, try return your environment into previous working state
relog, (logout, login)
repair your system perl. Thats mean,
read #Sam Varshavchik's answer
reinstall it from your distribution, using your package manager (5.10).
this step should overwrite the mess you caused.
test it !
don't continue until youre ensured, everything working right as before.
Lesson learned: never overwrite your system perl
learning
read thru perlbrew.pl
repeat previous step once again, especially with the
the homepage
http://perlbrew.pl/Perlbrew-and-Friends.html
https://metacpan.org/pod/App::perlbrew
https://metacpan.org/pod/perlbrew
installing perlbrew
run the installation command \wget -O - http://install.perlbrew.pl | bash
should finished without errors
follow the instructions how to modify your startup file e.g. ~/.profile or such... (you need to add one line to the end)
check your ~/perl5/perlbrew/bin should contain prelbrew and patchperl
relog
setup new perl, run
perlbrew init #init environment
perlbrew available #show what perl you can install
perlbrew install 5.20.0 #will take few minutes - depends on your system speed
perlbrew install-cpanm
perlbrew list #check
perlbrew switch perl-5.20.0 #activate newly installed perl 5.20
Check your installation
in the ~/perl5/perlbrew/bin you should have 3 scripts: prelbrew , patchperl , cpanm
perl -v should return 5.20
type cpanm - should return ~/perl5/perlbrew/bin/cpanm
You're done.
CPAN modules
You can install new modules with cpanm, like:
applications
cpanm cpan-outdated
cpanm App::Ack
cpanm Unicode::Tussle
cpanm Perl::Tidy
cpanm Perl::Critic
collections
cpanm Task::Moose
cpanm Task::Plack
cpanm Task::Unicode
modules
cpanm Path::Tiny
cpanm Try::Tiny
cpanm JSON
cpanm YAML
etc...
Check the ~/perl5/perlbrew/perls/perl-5.20.0/bin/ for new commands
You will need update your own perl script's shebang line to
#!/usr/bin/env perl
I hope don't forget anything, maybe other more experienced perl-gurus will add/edit/correct more.
Anyway, in the reality the steps 5,6,7 are much easier as sounds (by reading this) and could be done in few minutes.
On rpm-based Linux distributions, you should never install system software manually, like this, by trying to compile and build it yourself. RHEL's package management tool, rpm, performs an important function of keeping track of dependencies between packages, and prevent package conflicts.
The errors you showed are precisely the symptoms of a corrupted system Perl installation, and rpm exists precisely to avoid this sort of thing happening. Manually building and installing random tarballs completely bypasses the safety net that rpm provides.
There's no cookie-cutter recipe for recovering from a corrupted system install of a critical system rpm like perl, but in general:
1) run "rpm -q" perl, this will show you the exact version of the perl rpm package that rpm thinks should be installed.
2) go to the RHEL installation media/directory, verify that it contains the same perl-.x86_64.rpm package. If you previously installed RHEL updates, it's possible that you already updated perl, so look for the version that rpm tells you have installed in the RHEL update directory, and verify that you have the correct rpm package.
3) Execute:
rpm -ivh --force perl-<version>.x86_64.rpm
This will reinstall the original perl RPM package that was previously installed. Your problem is not only that you have extra versions of perl installed, but that it's likely that some of your custom perl builds have clobbered the system perl package, and uninstalling them won't help, you have to reinstall the system perl.
4) In RHEL, many perl modules are installed as separate packages. The above process should be used to reinstall every perl rpm package that you have installed. Execute:
rpm -q -a | grep '^perl'
This will give you a list of all Perl packages you have installed. You will need to repeat this procedure for every Perl rpm package.
It's not a 100% guarantee that this will fix everything, there could be other things wrong too, but this is a good first step towards recovery.
What I have done:
From #Sam-Varshavchik answer:
Found the previous perl rpm in my yum cache, and installed ...
rpm -ivh --force perl-<version>.x86_64.rpm
Checked for others "perl*" previously installed packages ... there were +260 so saved it in a file rpm -qa "perl*" > /tmp/perl.pkgs
With +260 packages to install, I realized that do it manually would take too much time, so it was time to put some ksh skills in practice ...
I checked at my yum cache and found ~130 of the +260 packages, so
took out from the list the base perl package (that I already have installed);
for those in the cache, I decided to install then with rpm, in the same way as the base package;
for those that I did not have handy, I used yum, which would download and do the same
of rpm, so ...
CACHE="/var/cache/yum/x86_64"
for perlpkg in $(cat /tmp/perl.pkgs)
do
FILE=$(find $CACHE -name "${perlpkg}.rpm")
if [[ ${FILE} != "" ]] ; then
rpm -ivh --force ${FILE}
else
yum -y reinstall ${perlpkg}
fi
done
From #jm666:
Installed perlbrew (was able to got it from my auth repos, so got it using yum) and using perlbrew, installed 5.20.0 localy
TODO: Didn't got any additional modules and neither Padre yet ... need to learn more about the way perlbrew works and isolate the installed version away from the system perl
Once again, thanks #Sam-Varshavchik and #jm666 for your support ang guidance

find whether a library is installed using shell script

I'm complete noobs in shell script what i want is shell script that determine a list of library/package currently installed if not install them without user permission
What I want is to determine the library/package is currently installed or not in system
I'm aware of aptitude search command but I looking for a better solution
e.g I have define(in shell script) check for readline library/package now how can I from inside the shell script (I want to create) know that readline package is currently installed or not.
Any idea or suggestion would certainly help
What I want is to determine the library/package is currently installed or not in system
dpkg -s does not require root permission, and will display package status details.
Example shell script:
#!/bin/sh
for P; do
dpkg -s "$P" >/dev/null 2>&1 && {
echo "$P is installed."
} || {
echo "$P is not installed."
}
done
Usage is:
script.sh package1 package2 .... packageN
For simply doing the test, it would seem that you could grep the output of a command such as ldconfig -p for your library of interest.
Or you could supply a tiny test program linked against the desired library, try running it, and test for non-failure.
If you are trying to set up a dependency check, the proper solution is to create a dummy package which Depends: on the packages you need to have installed. There is a tool called equivs which somewhat helps with this. (However, it has been criticized as being "over-engineered"; certainly, if you are familiar with the format of Debian packages, you might not need a separate tool if your requirements are this simple.) Then you just install this package and it will pull in the packages which are specified as dependencies.
You still have to know that the library which provides libreadline.so is libreadline5-dev. Debian package search can help find the package names you need to put in Depends:
You can probably do what you want with dpkg

CPAN giving all sorts of errors on ubuntu

I am just trying to run a simple perl program to import data from xml and export it to database.
Use Mysql; did not work, so I used DBD::mysql instead after failing to get Mysql.pm from cpan.
However, I am unable to install anything. I am trying to install xml parser module, but cpan gives these errors no matter what module you try to install.
install xml::parser
CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
CPAN: Compress::Zlib loaded ok (v2.02)
............................................................................DONE
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
CPAN: Time::HiRes loaded ok (v1.9719)
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
DONE
Going to read '/root/.cpan/sources/modules/03modlist.data.gz'
Catching error: "Can't locate object method \"data\" via package \"CPAN::Modulelist\" (perhaps you forgot to load \"CPAN::Modulelist\"?) at (eval 29) line 1.\cJ at /usr/share/perl/5.10/CPAN/Index.pm line 518\cJ\cICPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl/5.10/CPAN/Index.pm line 85\cJ\cICPAN::Index::reload('CPAN::Index') called at /usr/share/perl/5.10/CPAN.pm line 955\cJ\cICPAN::exists('CPAN=HASH(0xa225610)', 'CPAN::Module', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1243\cJ\cICPAN::Shell::expandany('CPAN::Shell', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1639\cJ\cICPAN::Shell::rematein('CPAN::Shell', 'install', 'xml::parser') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1935\cJ\cICPAN::Shell::__ANON__('CPAN::Shell', 'xml::parser') called at /usr/share/perl/5.10/CPAN.pm line 375\cJ\cIeval {...} called at /usr/share/perl/5.10/CPAN.pm line 372\cJ\cICPAN::shell() called at /usr/bin/cpan line 198\cJ" at /usr/share/perl/5.10/CPAN.pm line 391
CPAN::shell() called at /usr/bin/cpan line 198
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Line-Count header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
Warning: Your /root/.cpan/sources/modules/02packages.details.txt.gz does not contain a Last-Updated header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
cpanDONE
Going to read '/root/.cpan/sources/modules/03modlist.data.gz'
No history written (no histfile specified).
Lockfile removed.
Can't locate object method "data" via package "CPAN::Modulelist" (perhaps you forgot to load "CPAN::Modulelist"?) at (eval 31) line 1.
at /usr/share/perl/5.10/CPAN/Index.pm line 518
CPAN::Index::rd_modlist('CPAN::Index', '/root/.cpan/sources/modules/03modlist.data.gz') called at /usr/share/perl/5.10/CPAN/Index.pm line 85
CPAN::Index::reload('CPAN::Index') called at /usr/share/perl/5.10/CPAN.pm line 692
CPAN::all_objects('CPAN=HASH(0xa225610)', 'CPAN::Distribution') called at /usr/share/perl/5.10/CPAN/Shell.pm line 1046
CPAN::Shell::failed('CPAN::Shell', 2, 1) called at /usr/share/perl/5.10/CPAN.pm line 413
eval {...} called at /usr/share/perl/5.10/CPAN.pm line 413
CPAN::shell() called at /usr/bin/cpan line 198
Am I doing something wrong? I tried searching for these errors, but no one has a right solution. Is there some setting in the config I should change?
If nobody has an answer for your particular problem I would probably just try with a new cpan, something like:
cd && mv .cpan .cpan-bak
and then trying to install the module again.
Hope this helps.
I had a similar problem.
Situation:
trying to install Catalyst::Plugin::AutoCRUD
using perl version: perlbrew-5.14.2
solution:
problem was the sudo i was prefacing to the cpan install command like this:
DIDNT WORK:
sudo cpan Catalyst::Plugin::AutoCRUD
WORKS:
chown -R myusername:myusergroup ~/.cpan
cpan Catalyst::Plugin::AutoCRUD
Reason: because i had perlbrew + cpan installed under my user account, NOT as root, all subsequent cpan module installs must be made with same user.
I had the same problem when my connection to the perl site timed out. The /root/.cpan/sources/modules/02packages.details.txt.gz contained only the information that the network timed out, and the /root/.cpan/sources/modules/03modlist.data.gz was also junk.
By removing just these files and trying again when the network was less busy, the files were then fetched correctly and everything worked fine again.
Check that your version of "cpan" (your installation program) matches your "perl" version...
Check this by doing: cpan --version and perl -v
I came across this same error while trying to install another module and it turned out that the version of "cpan" that I was using was compiled as part of the 5.8.8 perl package but the version of "perl" that is set as default here at work is version 5.8.5, so cpan was compiling the C code using references to the wrong 5.8.8 perl base library that was not compatible when implemented by the 5.8.5 perl base.
The simple solution was to call the proper "cpan" program using the full path "/usr/.../perl/5.8.5/bin/cpan module_name".
This little inconsistency of having different binaries of different version packages being default is a an oversight by our administrators and has really caused a lot of grief.
To resolve this issue I had to install cpanm on Centos7.
Steps:
yum install perl-devel
yum install perl-CPAN
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
Add local bin (/usr/local/bin) to PATH using:
PATH=$PATH:/usr/local/bin
Links
http://www.canfield.com/on-error-do/install-cpanminus-in-centos-6-aka-cpanm
http://www.cpan.org/modules/INSTALL.html
In my case, I needed to run cpan with sudo -H to get my local network setitngs (like proxies). So:
cd && mv .cpan .cpan-bak
Then:
sudo -H cpan
Default answered to cpan configs (this time the errors didn't appear).
Then I was able to install any module.

Resources