Home: Perl Programming Help: Advanced:
cpan Couldn't create directory /.cpan


Aug 28, 2015, 11:56 AM

Views: 15015
cpan Couldn't create directory /.cpan

perl5 (revision 5 version 8 subversion 7) configuration Mad


I am in an environment with a fairly old Perl and I've discovered that the didn't even have a cpan utility. So what do you do? You go to cpan.org and download it., then build it. The trouble is, since I had no cpan utility, I have to handle all the dependencies manually and back up/resume every time I had to download another module. In the end, I had downloaded & installed:
- CPAN-Test-Dummy-Perl5-Make-1.05
- CPAN-Test-Dummy-Perl5-Make-CircDepeOne-1.00
- CPAN-Test-Dummy-Perl5-Make-CircDepeThree-1.00
- CPAN-Test-Dummy-Perl5-Make-CircDepeTwo-1.00
- CPAN-Test-Dummy-Perl5-Make-Zip-1.03
before finally getting a clean "make" on CPAN-2.10 itself.

Now I try to run the cpan utility for the first time in my home directory. Note that I will opt for the "sudo" option for installing modules. Here's the session:

$ cpan 
Loading internal null logger. Install Log::Log4perl for logging messages
The system CPAN configuration file has provided some default values,
but you need to complete the configuration dialog for CPAN.pm.
Configuration will be written to

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes]

Use of uninitialized value in concatenation (.) or string at /usr/local/lib/perl5/5.8.7/App/Cpan.pm line 633, <STDIN> line 1.

Warning: You do not have write permission for Perl library directories.

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')
[local::lib] sudo

Couldn't create directory /.cpan.
Please retry.
.... (until I CTRL-C out of it)

Note the error message in red:

The message about Loading internal null logger: When I tried to make Log::Log4perl, every blessed (ahem) pm module had a compile error in the POD: The directive =encoding utf8 is not understood. I'd have to run a massive sed and save operation to fix all of that. So I will make do with the null logging. Frown

But the Use of uninitialized value is quite the gluteal pain! The actual line of code are:

631     *CPAN::Shell::myprint = sub { 
632 my($self,$what) = @_;
633 $scalar .= $what;
634 $self->print_ornamented($what,
635 $CPAN::Config->{colorize_print}||'bold blue on_white',
636 );
637 };

But, as you can see, the cpan program keeps going, to ask me how to handle my privileges. I reply "sudo" and then begins that endless loop about "Couldn't create directory /.cpan."

Actually, it did. And therein is subdirectory CPAN. And in .cpan/CPAN is file MyConfig.pm. Looks good, eh? Except its whole content is:

As I write this, it occurs to me: Perhaps I need an older release of CPAN.pm for my decrepit release of Perl?? Ah, but which one? CPAN offers so MANY old releases!

Maybe it would not even have so many dependencies.

I'm open to ideas about this. Specifics (like which release of CPAN) would even better.

Thanks much!
-- Rasputin Paskudniak (In perpetual pursuit of undomesticated, semi-aquatic avians)

Veteran / Moderator

Aug 28, 2015, 12:07 PM

Views: 15011
Re: [rpaskudniak] cpan Couldn't create directory /.cpan

I am in an environment with a fairly old Perl

5.8.7 is not "fairly old" it's ancient.

If you need to update or install new modules for the system perl, you should "sudo bash" first, then do your install. If you don't have "sudo bash" rights, then you need to either have someone else install it for you, or use perlbrew to install a new version of perl under your home directory so that you have full control over it.

(This post was edited by FishMonger on Aug 28, 2015, 12:10 PM)


Aug 30, 2015, 1:24 PM

Views: 14933
Re: [FishMonger] cpan Couldn't create directory /.cpan

Oh dear!

Of course I had sudo rights, Fishmonger; else I would not have been able to successfully "make install". The actual install command was:

$ sudo make install

My problem is not about installing cpan itself, although I described a bunch of problems with that aspect as well. (In retrospect, I should have omitted all that but it was too late for me to think that straight. Blush)

The problem occurred when I was trying to execute the cpan command, which does not require sudo privileges in my own blessed home directory. The code I quoted - the location of the run-time error - indicates that this function expects 2 parameters but seems to have been called with 1 parameter, likely owing to the age of the Perl. I suspect an older release of CPAN.pm would have a one-parameter version of that function. Unsure My main question was: Which release of CPAN.pm does this? Crazy
A bigger question might be: How would I go about determining this, short of downloading every blessed release, unTARring it, and examining that function? (So that I would not have to post a question in this forum.)

And yes, it is an ancient version of Perl my client is using. I have been trying to help my manager make the case with this client that they MUST upgrade a few things, like their release of the OS, the database engine (before the vendor grandfathers this one) and Perl. Unfortunately, VLCs (very large clients Wink ), victims of their own success, tend to be a bit constipated in this area.

Again, thanks for a guiding hand.
-- Rasputin Paskudniak (In perpetual pursuit of undomesticated, semi-aquatic avians)

Veteran / Moderator

Aug 31, 2015, 8:26 AM

Views: 14901
Re: [rpaskudniak] cpan Couldn't create directory /.cpan

Note the error message in red:

The items in red are not errors. The first one is simply an info message. The second one is a warning, not an error.

I'm not sure what you were expecting make Log::Log4perl to do. That's not how to install a module or how make is used.

The permission warning is not referring to creating the .cpan directory under your home directory; it's referring to the / directory and at this point I'm not sure if you were running the command with sudo rights or not.

What System (OS) are you working on? You can get a fairly good idea if the latest cpan will work on your system from here: http://matrix.cpantesters.org/?dist=CPAN+2.10. You can also look at older releases to see which one has the best chances of working on older perl's.

Since you're wanting to install this for the system perl, then start by doing what I first suggested, which was to sudo bash first, then do the install. This resolves the possible problem of forgetting to run one or more of the commands under sudo rights.

(This post was edited by FishMonger on Aug 31, 2015, 8:27 AM)


Aug 31, 2015, 10:02 PM

Views: 14870
Re: [FishMonger] cpan Couldn't create directory /.cpan

Oy! Mad

I posted the first message out of sheer, cussed stubbornness; I was sure that, with help from this forum, I could get modules installed the proper way.

Well, with more discoveries about my environment, my notorious stubborn streak has finally cracked! Pirate There are too many possible ways to go about this, none of which guarantee success. It was built by the Borg and persistence is useless.

The only way I will be able to get this environment (of over a dozen Solaris hosts) into shape is by convincing the client to upgrade their Perl to the latest; I believe a working cpan with come alone for the ride with that. Or will at be compilable. Until that happens, I will be installing modules manually. Frown

Thanks for trying to help, FM.
-- Rasputin Paskudniak (In perpetual pursuit of undomesticated, semi-aquatic avians)