Item6028: build.pl fails in cleanup after building a plugin
Priority: Low
Current State: Closed
Released In:
Target Release: n/a
build.pl fails in cleanup. It appears to try to remove a /tmp directory that no longer exists.
(in cleanup) Can't call method "FETCH" on an undefined value at /usr/lib/perl5/5.8.8/File/Path.pm line 185 during global destruction.
at /var/www/SVN/twiki/core/lib/TWiki/Contrib/Build.pm line 66
TWiki::Contrib::Build::__ANON__('Can\'t call method "FETCH" on an undefined value at /usr/lib/...') called at /usr/lib/perl5/5.8.8/File/Path.pm line 185
File::Path::_rmtree('/tmp/1Fq7KuQNXi', '', '/var/www/SVN/twiki/ToolTipPlugin/lib/TWiki/Plugins/ToolTipPlugin', 773, 43794, 'undef', 0) called at /usr/lib/perl5/5.8.8/File/Path.pm line 304
File::Path::rmtree('/tmp/1Fq7KuQNXi') called at /var/www/SVN/twiki/core/lib/TWiki/Contrib/Build.pm line 314
TWiki::Contrib::Build::DESTROY('TWiki::Contrib::Build=HASH(0x8159c28)') called at build.pl line 0
eval {...} called at build.pl line 0
The fix appears to be to change Build.pm to test if the directory exists before removing it.
sub DESTROY {
my $self = shift;
- File::Path::rmtree( $self->{tmpDir} ) if $self->{tmpDir};
+ File::Path::rmtree( $self->{tmpDir} ) if $self->{tmpDir} && (-d "$self->{tmpDir}");
}
--
TWiki:Main/GeorgeClark - 29 Sep 2008
Even though I think your fix deals with this issue, it might be wise investigating the { error => \my $error_list } approach, as this will be more generic.
Otherwise, I'd perltidy your line
File::Path::rmtree( $self->{tmpDir} )
if $self->{tmpDir} && -d $self->{tmpDir};
But yes, I know, I'm picky, so ignore me
--
OlivierRaginel - 14 Dec 2008
I've had the fix floating around in my local SVN for several months, and had forgotten about it until it came back with the Foswiki svn checkout. Don't apologize for picky - It's an opportunity to learn. I was assuming that something is automatically removing the directory when it is no longer needed, so the delete is not always necessary. It fails every time on my system, but after the build is complete.
I don't understand the
{ error => \my $error_list }
approach - can you give me a couple of more hints. Does this capture the error for reporting? In this case, since the directory isn't there, I figured it was safe to just bypass the rmtree.
--
GeorgeClark - 14 Dec 2008