Subject: | "Can't call method close on an undefined value" error on make install |
I was getting the following fatal error on a Solaris 8 box when make
install was invoked via the cpan command line tool or the CPAN shell:
Running make install
Prepending /home/whatever/blah to PERL5LIB for 'install'
Can't call method "close" on an undefined value at
/usr/local/lib/perl5/5.6.1/CPAN.pm line 8987.
The filehandle in question is opened with:
"${make_install_make_command} install Module::Name 2>&1 |"
which was:
"sudo make install Module::Name"
on my system.
It looks like the CPAN shell runs in a restricted environment. In this
case, its PATH only contains:
/usr/ucb
/bin
/usr/bin
- and as a result the "make install" command barfed as the system's sudo
is contained in /usr/local/bin (as is its make). This is fine, but the
error is not reported and the undef return value from FileHandle->new()
is unchecked.
The patch is trivial:
8979c8979
< my($pipe) = FileHandle->new("$system $stderr |");
---
Show quoted text
> my($pipe) = FileHandle->new("$system $stderr |") || Carp::croak
("Can't execute $system: $!");
There are other unchecked calls to FileHandle->new() that may or may not
suffer from the same problem.
Thanks,
chocolateboy.