4

my admin has given me sudo rights for

cpan

I also need to install a couple of non-CPAN modules (Atlassian Crowd -> svn connector) to the global PERL5LIB.

I vaguely remember that cpan can install from local sources, without pulling modules from the web.

any pointers? can I do it or should I just have him install those modules manually as root (a major hassle for me)? thanks!

3 Answers 3

9

If you want to install the Perl distribution in the current directory, use the dot instead of a filename:

 cpan .

If you are using one of the latest versions of the cpan program (not the one that currently comes with CPAN.pm), you can use the -j switch to specify an alternate configuration file where you can set the --install_base or INSTALL_BASE directives, and also set values for options like connect_to_internet_ok.

 cpan -j /path/to/Config.pm Foo::Bar

If you want to modify your current config to make your alternate config file, use -J to get the file text:

 cpan -J

Ideally, instead for giving you superuser priveleges, that sysadmin would have created a group for Perl admins, would have specified a directory for module installations owned by that group, and added you to that group. You wouldn't need any special powers then.

3
  • well.... $ cpan -J Unknown option: J Nothing to install! $ cpan -j Unknown option: j Nothing to install! thanks anyway
    – webwesen
    Commented Oct 9, 2009 at 21:40
  • That's why I said you have to get the latest version. Which one are you using? Commented Oct 9, 2009 at 23:27
  • Totally agree with Brian's solution about a perl group - that avoids the root shell loophole I mentioned in my comment (now with an example).
    – Mark
    Commented Oct 10, 2009 at 12:47
1

You don't actually need your admin to give you rights to install CPAN modules. In fact local::lib is a better solution for a number of reasons.

2
  • 3
    local::lib isn't a better solution if you want to install the modules for all users. Commented Oct 9, 2009 at 19:14
  • How should I proceed If I don't have local::lib in the first place?
    – Ram
    Commented Dec 7, 2009 at 9:47
1

sudo rights to cpan -i should do the trick:

bash-3.2$ cpan -i Foo::Bar
CPAN: File::HomeDir loaded ok (v0.80)
CPAN: Storable loaded ok (v2.18)
...

I'm not familiar with installing from files via the cpan script. In the cpan shell you can look into the module directory and manually build/install from there if you want, but the original tar file still came from the repository, and the cpan command line doesn't seem to have that function (if it did I doubt the admin would grand sudo rights to it since then you'd have a root shell).

Update: brian d foy suggests that I'm wrong about giving sudo to the cpan command being the same as giving a root shell - here's why I'm right:

bash-3.2# whoami
aufflick
bash-3.2# sudo cpan
cpan[1]> o conf shell bash
cpan[2]> look Acme::Bleach
..... downloads and extracts Acme::Bleach ...
CPAN: File::Temp loaded ok (v0.18)
Working directory is /Users/aufflick/.cpan/build/Acme-Bleach-1.12-v768Dv
bash-3.2# whoami
root
bash-3.2# 
4
  • i should have been more clear. he gave me sudo for cpan and sudo for ./Build - this lets me install into global PERL5LIB
    – webwesen
    Commented Oct 9, 2009 at 15:53
  • If you specify a module name, it's always going to try to get it from a CPAN mirror. Commented Oct 9, 2009 at 19:26
  • Without any arguments, the cpan program drops you into the CPAN.pm shell. That's still not a root shell, though. You can only interact with CPAN.pm. Commented Oct 9, 2009 at 19:27
  • wow...wow...wow... I have to tell my admin how wrong he is. thanks a lot
    – webwesen
    Commented Oct 10, 2009 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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