Why did "cpanm Email::Sender::Simple" change directory permissions for other modules, breaking bugzilla? - perl

So I was working on a small Perl project and needed the Email::Sender::Simple module. I installed it, for some reason, via cpanm instead of cpan like I usually do:
cpanm Email::Sender::Simple
After installing the module, I checked my Bugzilla installation, and found that it was totally broken. The bugzilla homepage was just reporting an error. It wasn't able to find modules like Data::OptList, which wasn't on the #INC path.
I determined the problem was that the file permissions in /usr/local/share/perl/5.8.8 had been changed, with many directories now having permissions like this:
drwx------ 4 root root
That is, only root was allowed to look in the directory. Those directories need to be readable by my "www-data" user so that Bugzilla can find and use modules such as Data::OptList.
Bugzilla has a checksetup.pl script which often fixes file permission problems, but it did not fix or detect this problem.
I was able to get things working again via:
find /usr/local/share/perl/5.8.8 -type d -exec chmod 755 {} \;
After doing that, I'm back up and running. But I'm worried that other permissions might have been changed. And I can't understand why cpanm would be so bold, reconfiguring my file permissions.
Does anyone understand why cpanm would have altered permissions in /usr/local/share/perl/5.8.8 ? Might it have changed other things? Is there a way to prevent this from happening again? Is the "cpanm" command somehow different from "cpan" ?

Unlikely story :) http://search.cpan.org/grep?cpanid=MIYAGAWA&release=App-cpanminus-1.5007&string=chmod&i=1&n=1&C=0

Related

can I safely clone perl lib to another location on a computer?

I have my own personal perl instance, using perlbrew and a local cpan instance. I put in a bit of effort to get cpan to work for my local install. I've configured code and tested it using this perl.
I now want to ensure anyone on the computer can use the perl code I wrote, meaning ensuring that the cpan modules I used are available to all, even those that can't access my home directory.
Unfortunately, I can't configure and use cpan as root user. There are a few reasons why this would be difficult, but the biggest is that I am using my personal cert to authenticate myself as part of connecting to the CPAN repo (needed due to the configuration of the system). I don't want to make my cert available to everyone for connecting to CPAN.
I'm wondering if, instead of fixing the root cpan instance and trying to hunt down all the modules I'm using with cpan, I can simply copy the modules I already have. I'm running with the same perl version and on the same architecture, so the modules in my personal home directory should be the right ones.
The problem is that perllocal.pod seems to hard code locations relative to where my instal was done, so a simply copy paste is not enough. Is there another easy way, possible a perl utility, to copy my local CPAN modules and perl lib directory over to the root perl lib directory?
Probably, but why don't you just give them permission to your perlbrew-installed perl. Then just continue to use #!/home/ikegami/usr/perlbrew/perls/5.22.0t/bin/perl or whatever.
If you don't know exactly what you have installed, you could have a look at Dist::Surveyor
If you already know what all of your deps are, you can list them in a cpanfile and then take a snapshot with Carton and use the generated cpanfile.snapshot to install the correct versions in the new location
you can clone the whole CPAN to your server for everyone to install
minicpan -l ~/CPAN -r http://ppm.activestate.com/CPAN/ [-f]

Can't locate Config.pm in #INC

I have a Perl app on my development server that I would like to replicate on my local machine (mac osx). I'm not a perl programmer by trade (I'm a PHP/Rails developer), and the developer of this app is no longer around so I can't contact him for help. I've gotten pretty close to getting it to work. I was able to install all the packages using CPAN (at least I think I got them all) but I keep running into the following error:
Can't locate WebCNP/Config.pm in #INC (
#INC contains: /Library/Perl/5.16/darwin-thread-multi-2level
/Library/Perl/5.16
/Network/Library/Perl/5.16/darwin-thread-multi-2level
/Network/Library/Perl/5.16
/Library/Perl/Updates/5.16.2/darwin-thread-multi-2level
/Library/Perl/Updates/5.16.2
/System/Library/Perl/5.16/darwin-thread-multi-2level
/System/Library/Perl/5.16
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.16 .
)
at webcnp_lib.pl line 30.
On the server, the app's file structure looks like this:
/var/www/cgi-bin (empty dir)
/var/www/conf
/var/www/error
/var/www/html (empty dir)
/var/www/icons
/var/www/perl (the config file is located in this directory)
- /WebCNP/Config.pm
/var/www/ssi (all the .pl files for the app are located here, including all the JS and CSS files)
Line 30 of /var/www/ssi/webcnp_lib.pl has the following:
use WebCNP::Config;
Any ideas what I could be doing wrong?
Just so you know I've copied the file structure of the app from my development server to my local machine and created a virtual host so that it points to the app's root directory (/var/www).
Thanks in advanced for any insight!
was able to fix this with a symbolic link
ln -s /path/to/my/app/WebCNP /Library/Perl/5.16/WebCNP
I take this isn't a module from CPAN.
I would be a bit hesitant to use a symbolic link. This will work, but you're basically linking in a file you have under your own control to the master /Library directory on MacOS X. You delete your file, and that link won't be pointing to anything.
You can use use lib to add directories that contain your modules to the #INC directory:
use lib qw(/path/to/my/app);
This will now include this path for module searches.
If you rather install the module itself, why not simply copy it into /Lbrary/Perl/5.16 itself? It's what cpan would have done. At least this way, you're Perl module directory isn't dependent upon a link that can be removed.
/var/www/perl isn't present in #INC, so Perl won't look there. The most common approach to solve this for CGI scripts would be to add the following to your scripts (but not modules):
use FindBin qw( $RealBin );
use lib "$RealBin/../perl";
I was able to fix this with a symbolic link
ln -s /path/to/my/app/WebCNP /Library/Perl/5.16/WebCNP
Not sure if this is the most elegant approach, but seems to work well for this app. Thanks everyone for your replies! This has been very insightful.
Old post, I know, but there is a much more portable way. When you install the modules, you need to do two things.
Add the installation path to PERL5LIB (i.e. PERL5LIB=$PERL5LIB:/My/Module/Path/lib) in your environment configuration (.profile or other files which get read on system initialization)
Add a PREFIX to your perl Makefile.PL call (perl Makefile.PL PREFIX=/My/Module/Path)
It goes without saying that you need to make certain your Makefile.PL is written correctly.

CPAN error message

I was trying to use my CPAN, but when I typed in the following command. The errors occurred. A similar question was asked in this forum(install CPAN module), I tried that solution, but it did not work for me. I am wondering if anyone can drop a hint?
perl -MCPAN -e shell
Your configuration suggests that CPAN.pm should use a working
directory of
/home/bq/.cpan Unfortunately we could not create the lock file
/home/bq/.cpan/.lock due to 'Permission denied'.
Please make sure that the configuration variable
$CPAN::Config->{cpan_home} points to a directory where you can write a .lock file. You can set this variable in either a
CPAN/MyConfig.pm or a CPAN/Config.pm in your #INC path;
Try:
sudo perl -MCPAN -e shell
This is an old question , but if anyone is still looking. Mine worked with changing the folder permissions for the folder the i wanted to use.So use chmod to change the folder permission and the modules will install as required.

cannot change these permissions .CPAN

I have a problem when i want to install CPAN module
I type cpan to install cpan , but i get this error :
mkdir /home/cyrine/.cpan/CPAN: Permission >denied at
/usr/share/perl/5.10/CPAN/Shell.pm line 656
How can I change these permissions?
Probably the CPAN directory is owned by root; you can check this by doing ls -l /home/cyrine/.cpan.
There are two ways of fixing this:
If you have sudo access to the server, use that when installing and using CPAN.
Delete or rename the entire /home/cyrine/.cpan directory (either mv ~/.cpan ~/.cpan-old, or rm -rf ~/.cpan).
It appears that you have a permissions issue with your home directory. Maybe someone else installed Perl modules in your home directory, and therefore you don't own those folders?
If you can't resolve the underlying permissions issue, there are several approaches to installing Perl modules without root privileges. You could use these to install modules in another location that you do have permission to access.
Local::Lib allows you to maintain your own local library of Perl modules which you install in your home directory. It gives instructions for installing the module itself if you don't already have it.
Perlbrew is a very simple-to-use tool that allows you to maintain your own separate installation of Perl (and install modules) in your home directory.
If that isn't enough, browse through some of the previous questions on this issue for more.

How do I install a CPAN module site-wide while local::lib is present?

I've recently set up a new system and wanted to install Padre to check it out. The Padre install instructions specifically said to install local::lib, so I did so (although I've never had need of it before). I then went on my way installing several other modules, running CPAN from my normal user account with sudo to handle the root-required portions of the installation.
Then time came to test out one of the web apps these modules were needed to support and, lo and behold, apache couldn't find them. They loaded fine from the command line and a quick look in ~/perl5 confirmed my suspicion that local::lib had hijacked my CPAN sessions and installed these modules there instead of in a site-wide location, despite my CPAN config including
makepl_arg [INSTALLDIRS=site]
mbuildpl_arg [--installdirs site]
What do I need to do to my CPAN config so that modules will be installed site-wide even though local::lib is installed? Or will Padre work without it and I can just remove local::lib entirely?
(I do not want any modules installed under ~/perl5 unless Padre insists on them being there. My code under development has its own project-specific directory locations and everything else should be site-wide. I have no need for a private catch-all location.)
Got it. Per the instructions on local::lib's CPAN page, I had set export PERL_MM_OPT='INSTALL_BASE=~me/perl', which was overriding the setting in my CPAN config. A quick export PERL_MM_OPT= got me back to a proper install location.
On the one hand, that's what I get for following the instructions blindly. On the other, I would have expected o conf to show the actual config settings that are being used rather than those which are in the saved CPAN config (even if an environment variable is overriding them).
A quick export PERL_MM_OPT= got me back to a proper install location.
This didn't help me when I tried to install Starman globally. I had to edit /root/.bashrc to comment (or to delete) next lines:
export PERL_LOCAL_LIB_ROOT="$PERL_LOCAL_LIB_ROOT:/root/perl5";
export PERL_MB_OPT="--install_base /root/perl5";
export PERL_MM_OPT="INSTALL_BASE=/root/perl5";
export PERL5LIB="/root/perl5/lib/perl5:$PERL5LIB";
export PATH="/root/perl5/bin:$PATH";
Based on this comment, it seems that local::lib installs its own version of CPAN.pm. If this is the case, you may need to find the original CPAN.pm and make sure that that one is loaded when you run your CPAN shell. Something like:
perl -I /usr/lib/perl5 -MCPAN -e shell
might do it. You might also find perl -V useful to see what include path the Perl compiler is using for its modules.