Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have small problem cause everytime i issue

cpan YAML

or try to install any perl module it install's it inito /root/perl5 and with this any other user cannot use modules that I've installed as a root.

Even if I do

rm -frv /root/perl5 /root/.cpan

and rerun cpan YAML it still installs into root home dir. How can i change this ?

share|improve this question
2  
Since you're on Debian, I suggest you use dh-make-perl --cpan YAML. Of course, that is, assuming you can't use the distro libyaml-perl. –  derobert Sep 12 '12 at 20:08
add comment

3 Answers 3

up vote 2 down vote accepted

There exists a config file which defines the default settings. You can find the file under the cpan's install path under CPAN/Config.pm. The path is usally /usr/lib/perl5/<version>/.

My suggestion would be to adjust the values of makepl_arg and mbuildpl_arg in the global config file since perl modules are either build and installed via MakeMaker or Build. If you put this:

'makepl_arg' => q[INSTALLDIRS=perl INSTALLBIN=/opt/mycpanmodules/bin/ INSTALLARCHLIB=/opt/mycpanmodules/perl5/ INSTALLPRIVLIB=/opt/mycpanmodules/perl5/ INSTALLSCRIPT=/opt/mycpanmodules/perl5/ INSTALLMAN1DIR=/opt/mycpanmodules/man/ INSTALLMAN3DIR=/opt/mycpanmodules/man/],
'mbuildpl_arg' => q[--install_path lib=/opt/mycpanmodules/perl5/ --install_path arch=/opt/mycpanmodules/perl5/ --install_path script=/opt/mycpanmodules/bin/ --install_path bindoc=/opt/mycpanmodules/man/ --install_path libdoc=/opt/mycpanmodules/man/],

in your Config.pm all modules that are installed via cpan goes to /opt/mycpanmodules.

Eventually you have to set the environment variable

PERL5LIB=/opt/mycpanmodules/perl5

so that your local perl knows where to search for the additionally installed modules.

share|improve this answer
    
On Fedora (and RHEL), @INC includes (among other things) locations under /usr/local for just this purpose. I'm not sure of the situation on Debian offhand, but perl -V will show you. That way, you don't need to set PERL5LIB. –  mattdm Sep 12 '12 at 20:10
    
Good point! That would make things even a bit easier. We should therefore change /opt/mycpanmodules by the path given by perl -V that is a location under /usr/local. For some reason i get used to install all software not provided by the package management under /opt although /usr/local is officially correct for this purpose. Isn't it!? –  user1146332 Sep 12 '12 at 20:23
    
O_O what a very weird thing... perl -V helped I had this added at the end of my /root/.bashrc export 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/x86_64-linux-gnu-thread-multi:/root/perl5/lib/pe‌​rl5"; export PATH="/root/perl5/bin:$PATH"; and I did't add it. Could this be done by some package ? –  Dawid Sep 12 '12 at 21:25
add comment

Check your .bashrc. I found strange vars in mine:

/root/.bashrc:PERL_MM_OPT="INSTALL_BASE=/root/perl5"; export PERL_MM_OPT;

remove them and re-login.

share|improve this answer
add comment

You may also want to look into the dh-make-perl package which can build a .deb package from CPAN. you can either download the module first, or you can get dh-make-perl to download it for you.

Better yet, why not just install libyaml-perl which is the CPAN YAML package already packaged for debian?

As a rule of thumb, when looking for CPAN modules on debian, check the debian packages list first - there's a very good chance that what you want will already be packaged. If it isn't, an alternative probably will be (and, usually, that alternative is the best or one of the best of a bunch of similar modules).

e.g. apt-cache-search yaml | grep perl...on my system (debian sid), it produces this list:

$ apt-cache search  yaml | grep perl
libbest-perl - fallbackable module loader
libcgi-formbuilder-source-yaml-perl - Initialize FormBuilder application from YAML file
libcgi-session-serialize-yaml-perl - YAML and YAML::Syck support for CGI::Session's serializers
libclone-perl - recursively copy Perl datatypes
libconfig-any-perl - module to load configuration from different file formats
libconfig-merge-perl - umbrella interface to configuration modules
libconfig-yaml-perl - module for manipulating YAML-based configuration files
libcpan-meta-yaml-perl - reimplementation of a subset of YAML for CPAN Meta files
libdata-phrasebook-loader-yaml-perl - loader class for Data::Phrasebook using YAML
libdata-yaml-perl - Easy YAML serialisation of Perl data structures
libhtml-template-dumper-perl - Output template data in a test-friendly format
libmoosex-blessed-reconstruct-perl - Data::Visitor for creating Moose objects
libmoosex-yaml-perl - module to load Moose objects from YAML
libpadre-plugin-datawalker-perl - simple Perl data structure browser Padre
libpadre-plugin-yaml-perl - YAML support for Padre The Perl IDE
libparse-cpan-meta-perl - module to parse META.yml and other similar CPAN metadata files
libsql-translator-perl - SQL translation library
libtemplate-plugin-yaml-perl - simple Template Toolkit Plugin Interface to the YAML module
libtest-cpan-meta-perl - test module to validate package metadata for CPAN
libtest-cpan-meta-yaml-perl - test module to validate a META.yml file
libtest-yaml-meta-perl - transitional dummy package for obsolete Test::YAML::Meta
libtest-yaml-valid-perl - module to test for valid YAML
libvitacilina-perl - Perl feed aggregation library
libyaml-appconfig-perl - manage configuration files with YAML and variable references
libyaml-libyaml-perl - Perl interface to libyaml, a YAML implementation
libyaml-perl - YAML Ain't Markup Language
libyaml-shell-perl - The YAML test shell
libyaml-syck-perl - Perl module providing a fast, lightweight YAML loader and dumper
libyaml-tiny-perl - Perl module for reading and writing YAML files
perl-modules - Core Perl modules

you can then get details on each of the packages with apt-cache show, e.g.

$ apt-cache show libyaml-perl
Package: libyaml-perl
Version: 0.84-1
Installed-Size: 200
Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>
Architecture: all
Depends: perl
Recommends: libyaml-libyaml-perl | libyaml-syck-perl
Suggests: libyaml-shell-perl
Description-en: YAML Ain't Markup Language
 YAML is a generic data serialization language that is optimized for human
 readability. It can be used to express the data structures of most modern
 programming languages (including Perl, of course). YAML supports Unicode
 and there are implementations of the parser in many different languages,
 making it a rather portable serialization format.
 .
 Please note that the YAML module is currently a deprecated implementation
 in Pure Perl, which is probably slow on your system. The authors intend
 to change it to just be a front-end interface module for various YAML
 implementations. For now, YAML::Any is a module provided for this purpose,
 which simply selects the best YAML implementation available.
Homepage: http://search.cpan.org/dist/YAML/
Description-md5: 207c6e42686e3356a6c6e3a975e92075
Tag: devel::lang:perl, devel::library, implemented-in::perl
Section: perl
Priority: optional
Filename: pool/main/liby/libyaml-perl/libyaml-perl_0.84-1_all.deb
Size: 72812
MD5sum: 4e4ab9f980f050253d403002bc7e3e39
SHA1: 8f1837257d08b2eb3e7a5dbcfd73d6954b55cf98
SHA256: 6636a5794490b7bd6ddfd3f87b3e6a90b4f212d5115db641fae007e7b5
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.