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.
Related
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]
I'm taking a look into Perl as a total beginner. I want to try some CPAN modules.
When I run an install command on my Osx console, CPAN asks for a configuration with the following statement :
To install modules, you need to configure a local Perl library
directory or escalate your privileges. CPAN can help you by
bootstrapping the local::lib module or by configuring itself to use
'sudo' (if available). You may also resolve this problem manually if
you need to customize your setup.
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')
What is the difference between local::lib and sudo options ?
If I understand it well, it installs some modules locally on my computer. But I don't see any difference between the two config above.
If you use sudo, CPAN will use root to install the libraries in a central location where all users on the machine can access the files without any special configuration. If you use 'local::lib', it will create a library in your home directory and install the modules such that only perl programs that have been configured to look for modules in your home directory will find the modules.
Perl uses the special variable #INC to search for module paths. So you can install modules anywhere as long as you set #INC properly before you use them. This article explains the basics.
http://www.symkat.com/find-a-perl-modules-path
You can do all kinds of fun stuff with #INC; one of my favorite hacks it to put a function pointer in there and use custom perl code to lookup modules.
Good question. When you use local::lib, you can install Modules via CPAN User specific in an given directory. Assume you choose sudo as approach, you install Modules global.
Its like installing Node.js via npm. When you install a module with npm install -g <Modul>, its global installed and you can use it everywhere. But withouth that -g flag, its just available inside your current directory.
Its about the same here, except that you choose the default way of installing CPAN Modules.
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
I am on a Linux machine where I have no root privileges. I want to install some packages through CPAN into my home directory so that when I run Perl, it will be able to see it.
I ran cpan, which asked for some coniguration options. It asked for some directory, which it suggested ~/perl "for non-root users". Still, when I try to install a package, it fails at the make install step, because I don't have write access to /usr/lib/perl5/whatever.
How can I configure CPAN so that I can install packages into my home directory?
See local::lib.
Once you have it installed, you can do:
perl -MCPAN -Mlocal::lib -e 'CPAN::install(LWP)'
There's the way documented in perlfaq8, which is what local::lib is doing for you.
It's also a frequently asked StackOverflow question:
Why does installing certain CPAN modules require root privilege?
How can I install CPAN modules locally without root access (DynaLoader.pm line 229 error)?
How do I tell CPAN.pm to install all modules in a specific directory?
How can I install a CPAN module into a local directory?
How can I use a new Perl module without install permissions?
How can I use CPAN as a non-root user?
How can I install local modules with the cpan tool?
Curiously, none of these are suggested when I use your original question title (which is one of the reasons a good title is very important in finding your answer).
How do I keep my own module/library directory?
When you build modules, tell Perl where to install the modules.
If you want to install modules for your own use, the easiest way might be local::lib, which you can download from CPAN. It sets various installation settings for you, and uses those same settings within your programs.
If you want more flexibility, you need to configure your CPAN client for your particular situation.
For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:
perl Makefile.PL INSTALL_BASE=/mydir/perl
You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:
% cpan
cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
cpan> o conf commit
For Build.PL-based distributions, use the --install_base option:
perl Build.PL --install_base /mydir/perl
You can configure CPAN.pm to automatically use this option too:
% cpan
cpan> o conf mbuild_arg "--install_base /mydir/perl"
cpan> o conf commit
INSTALL_BASE tells these tools to put your modules into /mydir/perl/lib/perl5. See How do I add a directory to my include path (#INC) at runtime? for details on how to run your newly installed modules.
There is one caveat with INSTALL_BASE, though, since it acts differently than the PREFIX and LIB settings that older versions of ExtUtils::MakeMaker advocated. INSTALL_BASE does not support installing modules for multiple versions of Perl or different architectures under the same directory. You should consider if you really want that, and if you do, use the older PREFIX and LIB settings. See the ExtUtils::Makemaker documentation for more details.
CPAN way
run cpan command. If you don't have CPAN configurated, do it first! Otherwise, you will see the cpan prompt. In this case, type look local::lib and you will have a new shell prompt. In this new shell, run the bootstrap command configuring and compiling the module at same time as at bellow.
user#host:~/.cpan/build/local-lib-1.004003-UyX2wf$ perl Makefile.PL --bootstrap && make test && make install
Now, export some variables:
Path where local::lib will install things
echo 'eval $(perl -I$index.t/perl5/lib/perl5 -Mlocal::lib)' >> ~/.bashrc
And Perl variable to avoid user input
echo 'export PERL_MM_USE_DEFAULT=1' >> ~/.bashrc
Now load your bashrc running
source ~/.bashrc
Try to install running cpan <SOME_VALID_MODULE_NAMESPACE>
That's it! Now you can install modules using cpan without root privileges. But, remember that this will work just for the CURRENT USER including the root user !
cpanminus way
If you have this installed your sys admin deserves a beer!
Just run
$ cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
Open another terminal and run
$ env |grep PERL
You should see something like this:
PERL5LIB=$HOME/perl5/lib/perl5 PERL_MB_OPT=--install_base "$HOME/perl5"
PERL_LOCAL_LIB_ROOT=$HOME/perl5
PERL_MM_OPT=INSTALL_BASE=$HOME/perl5
But if you're not, export variables like this:
$ echo "export PERL5LIB=\"$HOME/perl5/lib/perl5\"">>~/.bashrc && \
echo "export PERL_MB_OPT=\"--install_base '$HOME/perl5'\">>~/.bashrc && \
echo "export PERL_LOCAL_LIB_ROOT=$HOME/perl5">>~/.bashrc
Finally, load your bashrc file and try to install with commands
source ~/.bashrc
and
cpanm <SOME_VALID_MODULE_NAMESPACE>
Fim!
I'd like to use a home directory specific, non-root directory for stuff I install from cpan. How can I configure it?
Normal CPAN configuration tries to install packages into /usr. After adding 'makepl_arg' => q[PREFIX=~/cpan_local], simple packages seem to build, but I cannot build a package that pulls its dependencies - the dependency is not found.
After I changed it to 'makepl_arg' => q[PREFIX=~/cpan_local LIB=~/cpan_local], I get the following message: Warning: Prerequisite 'ExtUtils::CBuilder => 0.27' for 'D/DA/DAGOLDEN/Module-Build-0.3607.tar.gz' already installed but installation looks suspicious. Skipping another installation attempt, to prevent looping endlessly.
How can I configure this properly? I want everything that's built to do to ~/cpan_local automatically. (or for people familiar with python, I'd like this to work like virtual-env and running easy_install from it).
Even better, install App::cpanminus first. Then just use it to install modules as a regular user. If this user can't write to the /usr/local/lib/perl* directories it will resort to writing in its home directory, or you pass it the -l or --local-lib option to directly install it in your home directory without it figuring out if it can install them system wide.
Finally, installing local::lib and setting up your environment automatically with your .bashrc file will allow you to omit the --local-lib option and install to your home directory directly.
Use local::lib. The bootstrap instructions should do the trick for you.