http://www.perlmonks.org?node_id=1013133

7stud has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I installed perlbrew (0.58) and one of the advantages of using perlbrew is stated on the homepage:

perlbrew is a tool to manage multiple perl installations in your $HOME directory. They are completely isolated perl universes. This approach has many benefits:

No need to run sudo to install CPAN modules, any more.

However, when I try to install cpan modules, I get errors like this:

Running install for module 'HTML::TreeBuilder'
Running make for C/CJ/CJM/HTML-Tree-5.03.tar.gz
mkdir /Users/7stud/.cpan/sources/authors/id/C/CJ: Permission denied at /Users/7stud/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/CPAN/FTP.pm line 519.

I checked all the permissions in the path listed in the error message:

mkdir /Users/7stud/.cpan/sources/authors/id/C/CJ

...and I own all the directories until the C directory. Here is the listing for the id directory:

~/.cpan/sources/authors/id$ ls -al
total 0
drwxr-xr-x  19 7stud  staff  646 Dec 31 03:23 .
drwxr-xr-x   5 7stud  staff  170 Jan 13 13:36 ..
drwxr-xr-x   6 7stud  staff  204 Dec 31 03:24 A
drwxr-xr-x   4 root   staff  136 Jan  1 02:53 B
drwxr-xr-x   4 root   staff  136 Jan  6 00:01 C
drwxr-xr-x   5 7stud  staff  170 Dec 31 03:21 D
drwxr-xr-x   3 7stud  staff  102 Dec 29 14:43 E
drwxr-xr-x   3 root   staff  102 Dec 31 03:23 F
drwxr-xr-x   3 7stud  staff  102 Dec 18 20:21 J
drwxr-xr-x   3 root   staff  102 Dec 18 20:42 K
drwxr-xr-x   3 7stud  staff  102 Dec 18 20:21 L
drwxr-xr-x   5 7stud  staff  170 Dec 18 20:22 M
drwxr-xr-x   3 7stud  staff  102 Dec 18 20:23 O
drwxr-xr-x   3 7stud  staff  102 Dec 29 14:52 P
drwxr-xr-x   3 root   staff  102 Dec 18 20:42 R
drwxr-xr-x   3 7stud  staff  102 Dec 18 20:23 S
drwxr-xr-x   5 7stud  staff  170 Jan  5 23:57 T
drwxr-xr-x   3 7stud  staff  102 Dec 18 20:25 Y
drwxr-xr-x   3 root   staff  102 Dec 31 03:22 Z

Some of those letter directories are owned by me, and some are owned by root. Should I just change the ownership of all those "letter directories" to 7stud, or is there a reason that perlbrew is giving root the ownership of some of those diretories?

Thanks.

Replies are listed 'Best First'.
Re: perlbrew -- permission denied problems
by aitap (Curate) on Jan 13, 2013 at 22:13 UTC

    It looks like somebody had already run cpan as root via sudo, and cpan created some directories (as root) in user's home directory.

    You can safely chown them back; use sudo -H next time you want to run CPAN shell as root to not pollute your home directory with files owned by root. Even better, you can set up a local::lib overlay in your home directory and install modules without requiring root priviledges.

    Sorry if my advice was wrong.
Re: perlbrew -- permission denied problems
by tobyink (Canon) on Jan 14, 2013 at 09:07 UTC

    It is probably a left-over in your ~/.cpan directory from when you used to run cpan as root. I'd recommend deleting your ~/.cpan/sources and ~/.cpan/build directories and recursively chowning the rest of ~/.cpan so that it is owned by your non-root username.

    Going forward I'd recommend running perlbrew install-cpanm and then using cpanm as your CPAN client.

    Or App::cpantimes :-)

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'