Item6028: build.pl fails in cleanup after building a plugin

pencil
Priority: Low
Current State: Closed
Released In:
Target Release: n/a
Applies To: Extension
Component: BuildContrib
Branches:
Reported By: TWiki:Main.GeorgeClark
Waiting For:
Last Change By: GeorgeClark
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 smile
    File::Path::rmtree( $self->{tmpDir} )
      if $self->{tmpDir} && -d $self->{tmpDir};
But yes, I know, I'm picky, so ignore me smile

-- 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

ItemTemplate edit

Summary build.pl fails in cleanup after building a plugin
ReportedBy TWiki:Main.GeorgeClark
Codebase
SVN Range TWiki-5.0.0, Tue, 23 Sep 2008, build 17539
AppliesTo Extension
Component BuildContrib
Priority Low
CurrentState Closed
WaitingFor
Checkins distro:928c48b4967d
TargetRelease n/a
ReleasedIn
Topic revision: r6 - 10 Jan 2009, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy