Installing CPAN modules without root - perl

I followed this helpful tutorial to get Perl installed just for my user. I am sorry to link to an external site but I think reading this is the only way to understand how to answer the question.
Anywho, I am feeding defaults to the CPAN config - the .cpan and CPAN directories created via the tutorial - yet for some reason CPAN still wants to dig into /usr/lib/ - which it just can't get to - when I try to install a module. This was while installing DBD::CSV.
Here is the error message:
All tests successful (7 subtests UNEXPECTEDLY SUCCEEDED), 3 tests skipped.
Files=23, Tests=706, 3 wallclock secs ( 2.28 cusr + 0.54 csys = 2.82 CPU)
/usr/bin/make test -- OK
Running make install
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/perl5lib/lib/Bundle/DBD'
mkdir /perl5lib: Permission denied at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 457
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
/usr/bin/make install -- NOT OK
It seems to be going to the wrong perl5lib.

Yeah, local::lib helps. I suggest using cpanm instead of cpan. I think it defaults to installing everything ~/perl5/lib/perl5. Here's a super useful tutorial.

local::lib causes installers to use INSTALL_BASE, which I consider broken. I use perlbrew to install a local copy of Perl instead.
You don't mess with your system's install of Perl, so you don't break your operating environment.
Allows you to have multiple versions and builds of Perl installed with no hassle.
INSTALL_BASE need not be used.
No need for special permissions.

take a look at this module: local::lib

did you configure the myconfig.pm inside cpan instead of letting it automatically fill in all the defaults? During the cpan configuration you needed to add PREFIX="" for the Makefile.PL portion so that it installs the modules to this new location where you have write access. Since its already configured automatically for you, go into .cpan/CPAN/, look for a MyConfig.pm and edit it. locate the line "makepl_arg" and change the value in [ ] to contain PREFIX="". Then try the perl -MCPAN -e shell and install a module.

Related

What does the command "cpan reports" do exactly?

I tried to install Moose in perl 5.32.0 with the command cpan install Moose. The installation failed, with the following message:
Result: FAIL
Failed 448/478 test programs. 12/30 subtests failed.
Makefile:2047: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255
ETHER/Moose-2.2013.tar.gz
13 dependencies missing (Class::Load,Class::Load::XS,Data::OptList,Devel::OverloadInfo,Dist::CheckConflicts,Module::Runtime::Conflicts,Package::DeprecationManager,Package::Stash,Package::Stash::XS,Params::Util,Sub::Exporter,Sub::Identify,Test::CleanNamespaces); additionally test harness failed
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports ETHER/Moose-2.2013.tar.gz
I tried the command cpan reports ETHER/Moose-2.2013.tar.gz, and somehow this installed Moose correctly. What happened here? What does cpan reports do exactly? Is this the same as App::cpanreports?
The error message there refers to something you can do in the CPAN.pm shell, and the cpan command doesn't have anything to map to that. Even if it did, it wouldn't look the same.
cpan with no arguments puts you into the CPAN.pm shell, and it's there that you can issue commands (such as install and whatnot). For reports, you need to install LWP and CPAN::Reporter first:
% cpan LWP CPAN::Reporter
...
% cpan
cpan[1]> reports ETHER/Moose-2.2013.tar.gz
Distribution: E/ET/ETHER/Moose-2.2013.tar.gz
Fetching 'http://www.cpantesters.org/show/Moose.json'...DONE
2.2013:
+PASS 5.28.0 on SunOS/Solaris 2.11 (i86pc-solaris-64)
+PASS 5.28.3 on GNU/Linux 5.4.34-0-lts (x86_64-linux-thread-multi)
+PASS 5.22.4 on GNU/Linux 5.4.0-26-generic (x86_64-linux)
+PASS 5.26.0 on FreeBSD 12.1-release (i386-freebsd-64int)
+PASS 5.26.0 on SunOS/Solaris 2.11 (i86pc-solaris-64)
However, it's probably easier to look on CPAN Testers to see the results for a particular module.
[You asked why using cpan reports ... instead of cpan install ... helped. This answers that. brian d foy's explains why cpan reports ... wasn't what you wanted to execute.]
It tries to install a module named reports.
The syntax for cpan is
cpan [options] <module_name> [<module_name> ...]
The operation is specified through options. The default operator is -i (install).
cpan install Moose
This command tries to install two distributions:
The newest one containing the module install.
A dummy module by this name was created, so this should not produce any errors.
Newer versions of cpan simply ignore this erroneous request.
The newest one containing the module Moose.
This is currently ETHER/Moose-2.2013.tar.gz.
cpan reports ETHER/Moose-2.2013.tar.gz
This command tries to install two distributions:
The newest one containing the module reports.
There's no module named reports, so that part fails.
>(error): Could not expand [reports]. Check the module name.
>(info): I can suggest names if you install one of Text::Levenshtein::XS, Text::Levenshtein::Damerau::XS, Text::Levenshtein, and Text::Levenshtein::Damerau::PP
>(info): and you provide the -x option on invocation.
>(error): Skipping reports because I couldn't find a matching namespace.
ETHER/Moose-2.2013.tar.gz
So,
cpan install Moose
is merely a bad way of writing
cpan Moose
Also,
cpan reports ETHER/Moose-2.2013.tar.gz
is merely a bad way of writing
cpan ETHER/Moose-2.2013.tar.gz
Currently, this should currently be equivalent to
cpan Moose
In other words, there's no difference between the command you claimed didn't work and the one you claimed worked.

INSTALL_BASE=~/perl5 -- NOT OK - While installing Perl Module

I am trying to install one of the Perl module in my local system (Windows 7). But its failing to install the module
Here is what its displaying
C:\Windows\system32>perl -MCPAN -e "install Net::SFTP"
Reading 'C:\Users\AppData\Local\.cpan\Metadata'
Database was generated on Sun, 26 May 2019 05:17:03 GMT
Running install for module 'Net::SFTP'
Checksum for C:\Users\AppData\Local\.cpan\sources\authors\id\L\LK\LKINLE
Y\Net-SFTP-0.12.tar.gz ok
Configuring L/LK/LKINLEY/Net-SFTP-0.12.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Math::Int64 0.54 not found.
Warning: prerequisite Net::SSH::Perl 2.12 not found.
The getpwuid function is unimplemented at C:/Perl64/lib/ExtUtils/MakeMaker.pm li
ne 1064.
Warning: No success on command[C:\Perl64\bin\perl.exe Makefile.PL INSTALL_BASE=~
/perl5]
LKINLEY/Net-SFTP-0.12.tar.gz
C:\Perl64\bin\perl.exe Makefile.PL INSTALL_BASE=~/perl5 -- NOT OK
It was working fine before and I have installed couple of modules, don't know what happens suddenly.
Please help me to resolve this. Do I need to make any modifications in config?
You're telling Perl to into ~/perl5. That's not a Windows path, and ExtUtils::MakeMaker is using a unix-specific function (getpwuid) to expand it. Your problem should go away if you use a Windows path.
That said, if you have access to write to C:\Perl64\..., I suggest that you install modules to the default directory by removing INSTALL_BASE=~/perl5.
If you don't have access to write to C:\Perl64\..., I suggest that you install Perl itself in a directly to which you do have access to write, and then I'd install modules to the default directory by removing INSTALL_BASE=~/perl5.
Since you didn't actually specify INSTALL_BASE=~/perl5 on the command line, you are specifying it through the environment (PERL_MM_OPT and PERL_MB_OPT), or in cpan's configuration (o conf from within cpan).

ubuntu 14.04 server perl POSIX install error

I don't know perl, I just needed POSIX as a dependency for a script. I have configured cpan answering the default questions and then, inside cpan,
install POSIX
I have been asked a million questions, answered default to all, and now the script is installing a million modules. Do I really need this ? I'm concerned if something goes wrong is it possible to undo this easily ?
UPDATE
well, what I feared just happened
Everything is up to date. Type '/usr/bin/make test' to run test suite.
./perl -Ilib installperl --destdir=
/usr/local/bin is not writable by you
make: ** [install-all] Erro 2
RJBS/perl-5.22.0.tar.bz2
/usr/bin/make install -- NOT OK
Failed during this command:
RJBS/perl-5.22.0.tar.bz2 : install NO
please, how can I fix this ?
POSIX is a core module included with Perl. You don't need to install it separately. Why don't you just install Perl via your package manager instead of from source?

Dependency problem of Perl CPAN modules

I tried to install SOAP::WSDL on Ubuntu 8.04 Server through CPAN but got the following error message:
cpan> install SOAP::WSDL
Running install for module SOAP::WSDL
Running make for M/MK/MKUTTER/SOAP-WSDL-2.00.10.tar.gz
Checksum for /root/.cpan/sources/authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00.10.tar.gz ok
SOAP-WSDL-2.00.10/
SOAP-WSDL-2.00.10/benchmark/
(skipped many lines)
SOAP-WSDL-2.00.10/README
CPAN.pm: Going to build M/MK/MKUTTER/SOAP-WSDL-2.00.10.tar.gz
# running Build.PL --installdirs site
Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'SOAP-WSDL' version '2.00.10'
Prereq '0.0.5' for 'Class::Std::Fast' is not supported by Module::Build::Compat
Running make test
Make had some problems, maybe interrupted? Won't test
Running make install
Make had some problems, maybe interrupted? Won't install
I have the latest versions of Class::Std::Fast and Module::Build::Compat:
$ perl -MModule::Build::Compat -e 'print $Module::Build::Compat::VERSION;'
0.3607
$ perl -MClass::Std::Fast -e 'print $Class::Std::Fast::VERSION;'
0.0.8
Any idea how to solve the problem? Perhaps I need to downgrade Class::Std::Fast to version 0.0.5?
Long story short, it looks like your CPAN installation is preferring to use the compatibility Makefile.PL instead of the Build.PL. It should prefer the Build.PL. The Makefile.PLs were intended for compatibility only and may not have all the features of Module::Build, such as supporting three part versions.
Fire up cpan. o conf will let you see your configuration. If prefer_installer isn't set to MB then do o conf prefer_installer MB. You may have to o conf commit to save it (it will tell you). You may also have to install Module::Build, either from the libmodule-build-perl package or from CPAN.
Bug reported to SOAP::WSDL.
PS You can work around this by installing Class::Std::Fast first, download SOAP::WSDL manually, edit the Build.PL to remove that dependency, and run cpan . in SOAP::WSDL's directory to install it and its deps.
What is your CPAN version? And configuration? (o conf at the cpan shell prompt.)
Hmm, that all looks ok. Unless for some reason CPAN wasn't able to load Module::Build?
Can you try the install again from a fresh CPAN shell, with no previous commands?
Or try doing a manual install without using CPAN.pm?
Try it,
cpan Module::Build
and
cpan Module::Build::Compat
And I forget to say something, the Ubuntu modify the packages if you are trying to install modules with root user, forget. Try again with local::lib.
After you do it, do:
cpan install CPAN
and finally,
cpan upgrade
It should solve your problem.

Make git-svn work on Slackware 12.1

It is obviosly some Perl extensions. Perl version is 5.8.8.
I found Error.pm, but now I'm looking for Core.pm.
While we're at it: how do you guys search for those modules. I tried Google, but that didn't help much. Thanks.
And finally, after I built everything, running:
./Build install
gives me:
Running make install-lib
/bin/ginstall -c -d /usr/lib/perl5/site_perl/5.8.8/i486-linux-thread-multi/Alien/SVN --prefix=/usr
/bin/ginstall: unrecognized option `--prefix=/usr'
Try `/bin/ginstall --help' for more information.
make: *** [install-fsmod-lib] Error 1
installing libs failed at inc/My/SVN/Builder.pm line 165.
Looks like Slackware's 'ginstall' really does not have that option. I think I'm going to Google a little bit now, to see how to get around this.
Base class package "Module::Build" is empty.
(Perhaps you need to 'use' the module which defines that package first.)
at inc/My/SVN/Builder.pm line 5
BEGIN failed--compilation aborted at inc/My/SVN/Builder.pm line 5.
Compilation failed in require at Build.PL line 6.
BEGIN failed--compilation aborted at Build.PL line 6.
is a (rather poor) way of asking you to install Module::Build.
Once you do that, it's
perl Build.PL
./Build
./Build test
./Build install
how do you guys search for those modules
http://search.cpan.org/
now I'm looking for Core.pm
That’s SVN::Core, which is a bit of a problem. Try installing Alien::SVN from CPAN. That worked for me on my freshly installed Slackware 12.0 on my laptop, but I have yet to get it to install on my workstation.
It should be compatible. The CPAN Tester's matrix shows no failures for Perl 5.8.8 on any platform.
Per the README, you can install it by doing:
perl Makefile.pl
make
make test
make install
I'm guessing you're running on Slackware so the cpan command is what you want to be using to install any Perl modules. It will pull in all dependencies for you. If you're running it for the first time it will have to do some cofiguration, but newer versions of cpan will ask if you want it to automatically configure it.
$ sudo cpan
cpan> install Alien::SVN
Additionally, if there's a package management application for Slackware, you should try that first to install new Perl modules.
https://metacpan.org/ is your first port of call for Perl modules.
What do you mean by "does not seem to be compatible"? Can you post the error message?
If the latest version does not work, you can select an older version in the "other releases" drop down and download that.
Edit: to those reading this, the author updated the question, so my answer seems a bit out of left field :)
The place to search is http://search.cpan.org.
I have my browser (Firefox) set up so that I can type "cpan foo" in the address bar and it will search CPAN for modules matching "foo." You can do this with either a keyword bookmark or by assigning a keyword to a search plugin.