How do I stop cpan from reconfiguring each time? + More - perl

I'm running on a Mac (version 10.6.3) and am struggling to understand what is going on with my Perl installation.
I let the system do a copy from my previous mac, and I appear to have a second perl installed, which appears earlier in my path. I can't tell (or remember) if I might have installed it with fink, macports or CPAN or what.
type -a cpan
cpan is /opt/local/bin/cpan
cpan is /usr/bin/cpan
I'm seeing two oddities. (To start with!) When I run cpan, and let it configure in ~lcuff/.cpan, each time I run it, it wants to reconfigure, giving the message:
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters...
Also, when I try to install File::Find::Rule (so I can list my CPAN modules, per the FAQ) I end up with an error message that I can't decipher or Google a solution for:
Use of inherited AUTOLOAD for non-method Digest::SHA::shaopen() is deprecated at /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level/Digest/SHA.pm line 55.
Catching error: "Can't locate auto/Digest/SHA/shaopen.al in \#INC (\#INC contains: /sw/lib/perl5 /sw/lib/perl5/darwin /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level /opt/local/lib/perl5/site_perl/5.8.9 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.9 /opt/local/lib/perl5/vendor_perl /opt/local/lib/perl5/5.8.9/darwin-2level /opt/local/lib/perl5/5.8.9 /Users/lcuff) at /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level/Digest/SHA.pm line 55\cJ" at /opt/local/lib/perl5/5.8.9/CPAN.pm line 359
CPAN::shell() called at /opt/local/bin/cpan line 198

I just went through my first migration to a new Mac last week, including a switch from fink and system perl to MacPorts and custom perl, so I remember the pain all too well...
As Schwern said, /opt/local is the default install location for MacPorts; fink uses /sw.
I did encounter a similar problem with CPAN configuration, although I didn't make any attempt to determine whether it was repeatable or not.
The first time I ran CPAN config, it said that I had an existing CPAN dir at ~/.cpan and stored the configuration there.
The second time, it wanted to configure into an existing CPAN dir at ~/Library/Application Support/.cpan. I didn't feel like repeating the CPAN configuration, so I broke out, did a quick cd ~/Library/Application Support/.cpan ; rm -rf .cpan ; ln -s ~/.cpan ., and it's worked great for me since then.
Hopefully this will at least help get you pointed in the right direction.

Have a look at Perlbrew.
Perlbrew allows you to install and manage mulitple versions for Perl under your home directory at ~/perl5
Installation is easy:
curl -LO http://xrl.us/perlbrew
chmod +x perlbrew
./perlbrew install
and simply follow the instructions.
Been using it for past few months on Mac OSX and it worked like a charm!
/I3az/

Related

trouble installing perl module with cpanm

I'm trying to install Vcf.pm from CPAN and am having no luck. Part of the problem is that I can't get cpanm to work.
This is where I started:
https://metacpan.org/pod/release/AJPAGE/Bio-Pipeline-Comparison-1.123050/lib/Vcf.pm
The Install Instructions (at the lower left if that page) gives 2 options:
cpanm Vcf
and
perl -MCPAN -e shell
install Vcf
For the second option, the first line goes okay but the second line returns:
Warning: Cannot install Vcf, don't know what it is.
Trying the first option, I get:
-bash: cpanm: command not found
That is strange, because I already installed cpanminus and it seemed to go okay, and when I give this command:
cpan App:cpanminus
I get this:
App::cpanminus is up to date (1.7044).
Can anyone help me get one of the above 2 options working so I can get the module installed? I'm just a humble dilettante where computer programming is concerned, but my understanding is that cpan is supposed to make installing modules easy, so I can't believe I've managed to fail at this!
It appears that the Bio::Pipeline::Comparison distribution is not indexed by PAUSE, so CPAN does not know how to install it. It's listed on MetaCPAN, but it was released seven years ago. The GitHub repository is missing and it's not in the author's CPAN directory. The module has disappeared. You might write to the author to ask where's it's gone if you are supporting legacy code. If you are doing new work, find something else to do the job.
As for the missing cpanm, it's probably installed but not in your PATH. You can force install it to and see where it ends up:
% cpan -f App::cpan minus

Date::Manip Not Installing

I keep getting error messages when trying to install the Date::Manip module. Any Perl experts know what I can try?
The command I'm trying is
perl -MCPAN -e "install Date::Manip"
Perl version is 5.20 and the version of the Date::Manip it keeps trying to install is 6.45, but it comes back with "Make had some problems" and "No such file in archive". It does prompt me to manually install the file, but i have no clue on how to do that. Here's what it says...
Could not find file 'sulbeck#heather.osg.ufl.edu.2024:1399465428' in memory at C:\Strawberry\perl\lib/CPAN/Tarzip.pm line 408.
Making symbolic link 'C:\STRAWB~1\cpan\build\tmp-3576\Date-Manip6.45\lib\Date\Manip\.#Changes6.pod' to 'sulbeck#heather.osg.ufl.edu.2024:1399465428' failed at C:\Strawberry\perl\lib/CPAN/Tarzip.pm line 408.
Could not untar with Archive::Tar SBECK/Date-Manip-6.45.tar.gz
Had problems unarchiving. please build manually. Stopping: 'install' failed for 'Date:Manip
I had exactly the same problem today.
I've been able to get 6.44 installed by doing the following from within the cpan cli (you can access this by simply typing cpan in your terminal).
The developer for Date::Manip has archived previous versions of the module, you'll need to add the backpan URL into your cpan config so you can search for it.
o conf urllist push http://backpan.perl.org/
Now you should be able to install using a direct path to version 6.44
install SBECK/Date-Manip-6.44.tar.gz
I had to accept that the checksum wasn't present in the package, but after that the module seemed to install correctly.
I suspect you'll want to keep an eye on the module and this bug report so that you can upgrade once it has been fixed.
perl -MCPAN -e "install 'SBECK/Date-Manip-6.44.tar.gz'"
or wait until the distribution is fixed. '.#Changes6.pod' is an illegal filename for your tar.

error running cpan the first time

I'm wondering if anyone can help me. I installed CPAN.pm via command line and then tried installing a module via CPAN. But I encountered an error:
Can't call method "http" on unblessed reference at /usr/lib/perl5/5.10.0/CPAN/FirstTime.pm line 1866.
This error can be resolved by entering the username and password fields in the proxy that cpan uses.
1] First Install cpan by
sudo yum install perl-CPAN
2] Then run the following command
cpan
It asks for setting basics, then select "NO" option for automatically picking then keep pressing enter till you are asked for "Automatically connect to internet", press no.
3] Then you will be asked for mirror details keep selecting from the list that it provided.
4] Then set the proxy username and password fields
5] Installation will then be complete and it will take you to cpan> prompt like below
cpan>
6] In the prompt enter
install Bundle::LWP
Firstly I'm surprised that CPAN isn't already installed as it has been part of the standard Perl distribution since Perl 5.004 was released fifteen years ago.
Secondly I'm surprised that you're still using Fedora 11. That version has been unsupported since June 2010.
Thirdly, I'm surprised that you want to use CPAN.pm as CPANPLUS and cpanminus are both far better interfaces to CPAN.
But given all of those surprises, if you want CPAN on your system, the best approach is probably to use the one that the Fedora project have pre-built for you.
$ sudo yum install perl-CPAN
There will be a number of CPAN modules available pre-build from Fedora. You can see them all using:
$ yum list available perl-\*
You'll find even more available for recent versions of Fedora.
You can almost certainly get CPANPLUS by installing perl-CPANPLUS. I doubt whether cpanminus is available for such an old version of Fedora.
I just had the same issue while installing Perlbrew.
After doing some debugging, I found out that this error happens because the CPAN logic could not find a mirror candidate. Of course, this could be improved in the CPAN::Mirrors or CPAN::FirstTime by just checking the results returned by the related functions.
Since those are not checked (and thus assumed that always returns some value) I got this meaningless error. But I must say I didn't checked further to see why no value is being returned after all.
You can safely avoid this error by simply selection No as answer for the automatic configuration. Of course, you will need to reply for each one of the configuration directives.
I got this while installing perl 5.16.3 thru perlbrew.
I had the same error, and did not have root privileges. The problem lay with there being two versions of cpan installed:
/usr/bin/cpan
/usr/local/bin/cpan
When I specified the former, things began to work.
replace Config.pm with fixed vertion
wget http://search.cpan.org/CPAN/authors/id/A/AN/ANDK/CPAN-2.16.tar.gz
tar -zxvf CPAN-2.16.tar.gz
sudo mkdir /usr/share/perl5/CPAN/ -p
sudo cp ./CPAN-2.16/lib/CPAN/FirstTime.pm /usr/share/perl5/CPAN/FirstTime.pm
source

Uninstall all perl modules installed by cpan

Yesterday I wanted to test some software and in the documentation it said, to install I just needed to type
cpan -i Software
I never used cpan, I just know that it is the perl package manager. (Is it..?) However, it turned out that I needed loads of dependencies, and stupid as I am, I just installed all of them. (First, I had to set up cpan which asked me lots of questions) Long story short, I just want to remove all of it again. I googled a bit, and it seems like cpan does not have an uninstall routine, especially for all the packages at once.
Can I just remove some directory or will I run into troubles?
the cpan command isn't really a package manager like apt-get is. It is more a tool that downloads and installs from CPAN (the site, or one of its mirrors). After it has finished this task it doesn't remember much about what was done before, at least not enough to remove previously installed modules, at least not reliably, cleanly or dependency-safely. (Update: After looking at App::pmuninstall, it can be used to handle dependencies, but it does so by connecting to outside (read: web) sources, which compute these separately, which is fine, but I stand by the previous statement that CPAN.pm doesn't do this.)
I used to worry about removing modules, but now I realize that most Perl modules take up so little room that I just don't worry about having a few extra modules installed that you will never use. So unless you are on a computer with a REALLY small disc, I would just let it be.
On Windows or if you are using a non-system Perl on Linux/Mac you could just remove Perl and reinstall it. I would not recommend this if you are using the system installed Perl on Linux/Mac however as you could break your OS doing this (you might be ok if you were careful, but not worth it to save a few Mb!).
In the future, you can easily install a local version of Perl using perlbrew, there are tutorials all over the web if the docs aren't sufficient (they should be). This also has the bonus of letting you play with the newest and greatest Perl versions, which your system likely doesn't come with yet. Then if you install a mountain of junk, or even break it doing something crazy, remove that version and reinstall/install a different version.
Another nice tool is cpanminus (or cpanm for short) which is a newer, more user friendly cpan tool. All the cool kids are using it.
You can uninstall individual modules with cpanplus (ships with Perl) like this:
cpanp uninstall SQL::Abstract
You can view all modules installed with the cpan script like this:
perldoc perllocal
Putting the two together:
for module in $(perldoc -u perllocal | grep -F 'C<Module> L<' | sed 's/^.*L<\(.*\)|.*>$/\1/') ; do
cpanp uninstall "$module"
done
I'm not sure about removing "all of it". But to remove a single module you can use App::pmuninstall with it's sole script pm-uninstall to uninstall modules. You might then be able to write some kind of script to recursively remove the deps.
If you can't use cpan any more because there are incompatible modules in you path, you can remove all installed modules by hand. For example, I upgraded from Fedora 22 to Fedora 23 and the Perl version changed. All modules installed previously via cpanm into /usr/local/lib64/perl5 did not work any more and prevented me from using cpanm.
$ cpanm --uninstall Apache::DBI
Attempt to reload Scalar/Util.pm aborted.
Compilation failed in require at /usr/share/perl5/vendor_perl/File/Temp.pm line 18.
...
I could solve this by moving that directory:
$ mv /usr/local/lib64/perl5 /root/usr-local-lib64-perl5
The name of that directory may vary on your system.
Carefull: If a module installed files outside of that directory, for example system library files, these files will remain there.
I will change Flimm's answer to use cpanm and optionally uninstall cpanm itself in the end of the script:
#!/usr/bin/env bash
for module in $(perldoc -u perllocal | grep -F 'C<Module> L<' | sed 's/^.*L<\(.*\)|.*>$/\1/' | sort | uniq) ; do
if [[ "$module" =~ "App::cpanminus" ]]; then
continue
fi
echo "Uninstalling $module..."
yes | cpanm --uninstall "$module"
done
cpanm --uninstall App::cpanminus
I think the best option is uninstall Perl and install it again.

How can I install Perl module without using CPAN.pm?

Is it possible?
If you download the source code, and read the README file. This will probably tell you you should do
perl Makefile.PL
make
make test
make install
or
perl Build.PL
./Build
./Build test
./Build install
If you download the source code, it will generally have a Makefile.PL. You run "perl Makefile.PL; make; make test; make install" and it will build and install for you.
Obviously if you're not using CPAN.pm, you're going to have to deal with dependencies yourself.
Also, if the reason you can't use CPAN.pm is that you don't have permission to install into /usr/lib/perl, you can force CPAN.pm to install locally, but I forget how.
If you are on a Linux box, a very large portion of the packages can usually be obtained using the built in package manager. For instance, on an Ubuntu system, if you want to install the PostgreSQL Perl module you'd simple do:
sudo apt-get install libpg-perl
You can see a list of the modules for Ubuntu here: http://packages.ubuntu.com/hardy/perl/
I find I can often guess at the names myself. Not sure if this helps at all, but for myself I often find this easier to use than CPAN as it does a lot better at resolving dependencies.
See here: How to install perl modules using CPAN without root
I have just set this up on a server without root access and CPAN does everything automatically.
But if you really wanna install a module without CPAN and you don't have root (assuming this since you don't wanna use CPAN), you can do it as follows
perl Makefile.PL PREFIX=$HOME
make
make install
You're gonna have to hunt down dependencies yourself so it's better to use CPAN.
If the problem is no root access, I would recommend looking at local::lib and also this webpage for CPAN.pm and non-root installation.
But to answer the question as asked, CPAN or CPANPLUS are helpful, but they aren't required. You can always do it the old-fashioned way as Leon says - though usually, it's easier not to.
If you are using Red Hat (Fedora, CentOS), you should use RPM for Perl dependencies wherever possible. Perl packages are almost always named perl-Module-Name, e.g. perl-DBI, perl-Spreadsheet-WriteExcel, etc.
On Ubuntu the naming scheme is libmodule-name-perl.
If the .pm file is pure Perl and doesn't need to be compiled you can just put it in your application's lib folder and use it as normal.
We can install all perl modules both from and even with your terminal in ubuntu. If you are using a ubuntu server then execute the following command ,
'sudo apt-get install "perl_module"'
The modules which you want just give the name in "perl_module" means If you want to install Apache2::Cookie it will be in "libapreq2" so you have to give like,
"sudo apt-get install libapreq2"
I, as others have would highly suggest using CPAN.pm. It is a breeze to use and can resolve any dependencies associated with the module you need automatically.
On the other hand, I would suggest that you read the perlmodinstall document over at perldoc as it gives details on other os' as well.
Regards,
Jeff
If you're asking this because you're having problems with CPAN... you're probably running out of RAM that's why you can't use CPAN.
Maybe you don't have a swap file. Try this:
$ sudo su
# dd if=/dev/zero of=/swap bs=1M count=1k # create a 1GB file
# mkswap /swap
# swapon /swap
Otherwise... stop some services.
$ sudo service mysql stop
$ sudo service nginx stop
...And try again
$ cpan install CPAN
$ cpan install MIME::Lite::TT::HTML