How best to handle previously installed modules when upgrading Perl version with homebrew - perl

I run into this every so often: I run a brew install foobar and as a result, Perl version gets updated. Whenever this happens, the Perl modules that I had installed are no longer found because they were installed in /usr/local/Cellar/perl/5.32.0/lib/perl5/site_perl/5.32.0/ and the new version is now looking in /usr/local/Cellar/perl/5.32.0/lib/perl5/site_perl/5.32.1_1/.
I have/had a ton of modules installed with the previous version and I'd rather not reinstall all of them (at least manually). What's the best way to have the previously-installed modules work with the new Perl version?
For such a small version change above, I could presumably just copy all of the files from the 5.32.0 dir to the 5.32.1_1 dir, but preferably there is a more general and/or robust solution for when the version change is more substantial.

The cpan command can make an "autobundle" file. You'd use the cpan from the prior installation to do this:
$ cpan -a
Creating autobundle in /Users/brian/.cpan/Bundle
Reading '/Users/brian/.cpan/Metadata'
Database was generated on Fri, 19 Mar 2021 05:41:03 GMT
Package namespace installed latest in CPAN file
Algorithm::C3 0.11 0.11 HAARG/Algorithm-C3-0.11.tar.gz
Algorithm::Cron 0.10 0.10 PEVANS/Algorithm-Cron-0.10.tar.gz
Algorithm::Diff 1.1903 1.201 RJBS/Algorithm-Diff-1.201.tar.gz
...
version::regex 0.9924 0.9928 LEONT/version-0.9928.tar.gz
vmsish 1.04 1.04 SHAY/perl-5.32.1.tar.gz
warnings 1.47 1.47 SHAY/perl-5.32.1.tar.gz
warnings::register 1.04 1.04 SHAY/perl-5.32.1.tar.gz
Wrote bundle file
/Users/brian/.cpan/Bundle/Snapshot_2021_03_20_00.pm
At the top of that file, there are instructions on installing it. Use the cpan from the new installation to handle this part:
package Bundle::Snapshot_2021_03_20_00;
$VERSION = '0.01';
1;
__END__
=head1 NAME
Bundle::Snapshot_2021_03_20_00 - Snapshot of installation on otter on Sat Mar 20 00:19:35 2021
=head1 SYNOPSIS
perl -MCPAN -e 'install Bundle::Snapshot_2021_03_20_00'
I hardly ever do this though. When I install a new perl and want to use a new project on it, I install the project. That project installs whatever it needs. I like the fresh start instead of carrying over stuff I might not be using anymore.
Also, note that cpan installs the latest versions of whatever you are asking for. If you need particular versions, cpanm is easier to handle. And, in that case, you might consider using a cpanfile to lock down exactly what you want.

Related

cpanm not finding newer version in local mirror

I created some proprietary Perl modules I can't share so I put them into a local "darkpan" with orepan2. Here is the beginning of 02packages.details.txt.
[~] $ gunzip -c darkpan/modules/02packages.details.txt.gz
File: 02packages.details.txt
URL: http://www.perl.com/CPAN/modules/02packages.details.txt
Description: DarkPAN
Columns: package name, version, path
Intended-For: Automated fetch routines, namespace documentation.
Written-By: OrePAN2 0.47
Line-Count: 30
Last-Updated: Wed Apr 24 15:44:46 2019
MyProj::MyMod 1.201904241840 D/DU/DUMMY/MyProj-MyMod-v1.20190424.1840.tar.gz
When I type
cpanm --mirror=file:///path/to/darkpan --mirror-only MyProj::MyMod
it responds that MyProj::MyMod is up-to-date even though the version in darktab is newer. To get it to install, I have to say "MyProj::MyMod-201904241840" on the command line.
Why won't cpanm recognize that the version in the darkpan index is newer than the one installed?
Why can't I just say
cpanm --mirror=file:///path/to/darkpan --mirror-only MyProj-MyMod
in order to load this as a module and not a single package?
as far as I know, cpanm is right, ‘up-to-dateness’ is based on the fact that something is installed that fits the minimal version specified... which you didn’t. correct me if i’m wrong, but there is a reinstall option that would do the trick and get any latest it can find

Install of Pod::Spell failing on Strawberry Portable 5.20.2

When I try to cpanm Pod::Spell on Strawberry 5.20.2 (64bit PortableZIP edition), it flags I18N::Langinfo as a dependency. When it tries to download the distribution for I18N::Langinfo it locates it in R/RJ/RJBS/perl-520.0.tar.gz and, wisely, thinks better of continuing.
Pod::Spell is of interest only as a dependency of Perl::Critic.
Any suggestions as to how to untangle this dependency issue?
It's a bug that Pod::Spell depends on this module, I didn't carefully enough check someone else's patch in the last release. I temporary fix would be to install the previous release as the only real changes in this release were to podspell and not the whole module. It will be fixed in the future.
Interesting. I looked for I18N::Langinfo on my self-built Perl on Windows, and it is not installed either. I would have expected it to be installed so that it could croak:
croak("nl_langinfo() not implemented on this architecture");
It seems to me the problem is not Strawberry or ActiveState specific (because I am building from source). It maybe worth building the current blead, and if I18N::Langinfo is still not being installed, reporting this as a bug to p5p.
Now, even if you could install the module however, I would not expect it to work with a non-Cygwin perl on Windows. Therefore, if Pod::Spell really depends on the module, it wouldn't work properly anyway.
But, frankly, looking at the code for Pod::Spell it is not immediately obvious to me why it should depend on I18N::Langinfo.
Therefore, I switched to cpanms work directory for Pod::Spell, and an nmake test (in your case, this would be dmake test with Strawberry Perl):
# *** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***
#
# The following REQUIRED prerequisites were not satisfied:
#
# I18N::Langinfo is not installed (any version required)
#
t\00-report-prereqs.t .. ok
t\basic.t .............. ok
t\debug.t .............. ok
t\get-stopwords.t ...... ok
t\text-block.t ......... ok
t\utf8.t ............... ok
All tests successful.
Files=7, Tests=24, 9 wallclock secs ( 0.13 usr + 0.02 sys = 0.14 CPU)
Result: PASS
Therefore, I went ahead, and installed the module using nmake install (in your case dmake install).
podspell seemed to work.
But, IMHO, you are better off just using aspell as in:
C:\...> aspell --mode=perl lib\Pod\Spell.pm
Note: I am using Aspell 0.60.6.1 installed using Cygwin.

Need help for installing LDAP in unix

I am following the below procedure for installing LDAP in unix
1.tar -xzf perl-ldap-0.43.tar.gz
2.cd perl-ldap-0.43
3.perl MakeFile.PL
I am getting below message
* Checking for Perl dependencies...
We have to reconfigure CPAN.pm due to following uninitialized parameters:
cpan_home, keep_source_where, build_dir, build_cache, scan_cache, index_expire, gzip, tar, unzip, make, pager, makepl_arg, make_arg, make_install_arg, urllist, inhibit_startup_message, ftp_proxy, http_proxy, no_proxy, prerequisites_policy, cache_metadata
CPAN is the world-wide archive of perl resources. It consists of about
100 sites that all replicate the same contents all around the globe.
Many countries have at least one CPAN site already. The resources
found on CPAN are easily accessible with the CPAN.pm module. If you
want to use CPAN.pm, you have to configure it properly.
If you do not want to enter a dialog now, you can answer 'no' to this
question and I'll try to autoconfigure. (Note: you can revisit this
dialog anytime later by typing 'o conf init' at the cpan prompt.)
Are you ready for manual configuration? [yes]
How to install without CPAN and what are the dependent modules required to install Ldap?
Can anyone suggest me the standard process of installation.
Thanks In Advance
I assume that by perl-ldap-0.43.tar.gz you are trying to install Net::LDAP
How to install without CPAN?
CPAN is the recommended way of installing Perl modules. You have to configure it just once, after that if you need to install any Perl module you can just type the below.
$ cpan ModuleName like in your case instead of downloading, untaring and running makefile you can just do:
$ cpan Net::LDAP
What are the dependent modules required to install Ldap?
One more advantage of using CPAN is you don't have to care about dependencies. CPAN will install dependencies automatically if you ask it to do so. Do it by
$ perl -MCPAN -e shell
cpan[1]> o conf prerequisites_policy follow
cpan[2]> o conf commit
exit
Or just use App::cpanminus and run
$ cpanm Net::LDAP it will install the module with all its dependencies.
Also check out Perl LDAP page.
Edit: Based on your answer
You will get some errors like above, you will have to see the error log, check the Module which is missing, then go to CPAN and download that module's tar.gz and then do the same steps as you were doing, like untaring, and running Makefile. You will have to do this unless all of your dependencies are installed.
Can we ignore warnings while installing perl modules?
I have installed ExtUtils-MakeMaker-6.98.tar.gz by ignoring below warnings
Using included version of ExtUtils::Install (1.54) as it is newer than the installed version (1.33).
Using included version of CPAN::Meta::YAML (0.008) because it is not already installed.
Using included version of JSON::PP::Compat5006 (1.09) because it is not already installed.
Using included version of ExtUtils::Manifest (1.60) as it is newer than the installed version (1.46).
Using included version of version (0.88) because it is not already installed.
Using included version of ExtUtils::Command (1.16) as it is newer than the installed version (1.09).
Using included version of CPAN::Meta (2.120351) because it is not already installed.
Using included version of JSON::PP (2.27203) because it is not already installed.
Using included version of File::Temp (0.22) as it is newer than the installed version (0.16).
Using included version of Parse::CPAN::Meta (1.4405) because it is not already installed.
Using included version of File::Copy::Recursive (0.38) because it is not already installed.
Checking if your kit is complete...
Warning: the following files are missing in your kit:
't/liblist/win32/di
't/liblist/win32/space
Please inform the author.
Generating a Unix-style Makefile
Writing Makefile for ExtUtils::MakeMaker
Writing MYMETA.yml and MYMETA.json**
But I'm able to install successfully. Will it create any problems in future?

How to fix Perl CPAN module error: version 0.82 required, this is only version 0.78?

Whether I use CPAN or install manually, every time I try to run "perl Makefile.PL" to build a makefile for a Perl module, I get the following error:
ERROR from evaluation of Makefile.PL: Can't locate object method "new" via package "CPAN::Meta" at /usr/lib/perl5/5.8.8/ExtUtils/MM_Any.pm line 1199
The CPAN::Meta module is installed, so I'm completely stumped on this one.
When run: perl -MCPAN::Meta -e1 it returns me the error:
version 0.82 required--this is only version 0.78 at /usr/lib/perl5/5.8.8/CPAN/Meta/Converter.pm line 12.
It seems that when installing ExtUtils::MakeMaker, version.pm (which is bundled inside EU::MM) was not upgraded. You need to upgrade it manually. root is required for this if you don't use local::lib.
I just had this same problem, here is a solution with description:
I was doing a "cpan Bundle::CPAN" which failed. When I re-ran I found that cpan was now broken and I couldn't install any modules. Worst still, "perl Makefile.PL" was also dying with the same error:
Can't locate object method "new" via package "CPAN::Meta" at /usr/lib/perl5/5.8.8/ExtUtils/MM_Any.pm line XXXX
When testing the CPAN::Meta module directly, I found the Parse::CPAN::Meta version was too old:
perl -MCPAN::Meta
Parse::CPAN::Meta version 1.44 required--this is only version 1.40 at /usr/lib/perl5/5.8.8/CPAN/Meta/Converter.pm line 13.
To be able to update Parse::CPAN::Meta, I had to first disable the use of CPAN::Meta in MakeMaker. I edited the file:
/usr/lib/perl5/5.8.8/ExtUtils/MM_Any.pm
And added "return 0;" after "sub _has_cpan_meta {" to make:
sub _has_cpan_meta {
return 0;
Then I was able to install Parse::CPAN::Meta as normal with "cpan Parse::CPAN::Meta". After which I confirmed CPAN::Meta was working "perl -MCPAN::Meta" and removed the "return 0" I'd added to /usr/lib/perl5/5.8.8/ExtUtils/MM_Any.pm.
Hey presto, all working again :)
Hope that helps anyone else who finds this thread.
If you've the error (as per comment about perl -MCPAN::Meta -e1):
version version 0.82 required--this is only version 0.78
then try upgrading it:
cpan CPAN::Meta
If you don't have access to install perl packages globally, run cpan and execute:
cpan> look CPAN::Meta
which will open a subshell in a distribution's directory, so you can download CPAN tar.gz manually and extract it there.
Source: Issues with installing Inline::Python
The up to date 'version' is here: https://metacpan.org/pod/version
ExtUtils::MakeMaker contains a stripped down version which says:
This is a modified copy of version.pm 0.9909, bundled exclusively for
use by ExtUtils::Makemaker and its dependencies to bootstrap when
version.pm is not available.
But in the code it says:
$VERSION = '7.36';
Try finding the location of CPAN::Meta and delete it or back it up and then try installing it again.

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.