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

I tried to install Tk for perl since I want to extend my perl knowledge to GUI programming. I open up CPAN, type in install Tk, and this happens:
cpan[5]> install Tk Running install for module 'Tk' Running make for S/SR/SREZIC/Tk-804.029.tar.gz Catching error: "mkdir /Users/fenimore/.cpan/sources/authors/id/S/SR: +Permission denied at /Library/Perl/Updates/5.12.3/CPAN/FTP.pm line 51 +9\cJ" at /Library/Perl/Updates/5.12.3/CPAN.pm line 392 CPAN::shell() called at -e line 1
Er… most of the problems I have had in the past were easily solved by simply changing permissions around in finder, but this time, I just don't know what's going on. Since it has to do with actual code, I probably shouldn't mess around with it. Can someone help me out here? And does anyone else have this problem?

Replies are listed 'Best First'.
Re: Problems with CPAN: installing Tk
by zentara (Cardinal) on Sep 15, 2011 at 09:49 UTC
Re: Problems with CPAN: installing Tk
by locked_user sundialsvc4 (Abbot) on Sep 14, 2011 at 22:21 UTC

    Sure... so to speak, lots and lots of people do.   This is really a specific case of a more-general concern.   Start by surfing the many posts on “installing Perl as a non-root user.”

    You see, here’s the issue...   you are (quite sensibly!) “just an ordinary user.”   (If you do happen to own a Superduperman Suit, you’re not wearing it now.   Wise Move.)   And CPAN, having not yet been instructed to do any differently (yet...), is attempting to install things into the “system-wide” locations, which you as an ordinary mortal have no read/write access to.

    But that certainly isn’t your only option, and, believe me, you really do want to leave all those system-wide directories well enough alone!   :-O   (Many operating systems and “distros” make use of Perl as the engine to run lots of their system-maintenance stuff.   You really don’t want to run the risk of disturbing any of that.)   Here’s the way to do it.   All of “your” CPAN materials will be installed into a set of directories that you can write to, and you’ll arrange for that directory to be considered first.   So you can have as many customized CPAN libraries as you care to.

    You set up your own separate you-writeable directory, and then you point CPAN to that location as the place to install things.   Then, add it to your PERL5LIB path.   All of which is neatly explained ... because this is exactly what folks have to do when they, say, install Perl-based web software on a shared-hosting system.   (Ditto PHP and Ruby and Python and every other language...)

Re: Problems with CPAN: installing Tk
by Anonymous Monk on Sep 15, 2011 at 00:21 UTC