MantisBT - CMake
View Issue Details
0010793CMakeCPackpublic2010-06-03 18:172010-06-07 08:36
Andras Lasso 2 
David Cole 
normalminorrandom
closedfixed 
CMake-2-8 
 
0010793: Problem removing toplevel directory on Windows 7
On Windows 7 CPack sometimes cannot remove the toplevel directory before packaging. Most of the time this happens when the directory contains an svn working copy.

Errors are reported also when trying to delete the directory using Total Commander. Delete is successfully completed when it is retried.

Process Explorer shows that the Windows Search Indexer tries to access the directory that cannot be deleted (see the attached screenshot). The indexer is configured so that the all the packaging/build directories are excluded, however it still seems to temporarily access the directory.

Although the issue is not specific to CMake (but due to an aggressive file locking by Windows Search Indexer and a bug in its directory exclude implementation), CMake could be made more robust to be able to work correctly even in this environment (retry failed delete operation N times after some delay, before giving up).
An example error log of a failed package creation:

1>------ Build started: Project: PACKAGE, Configuration: Release Win32
1>------
1>
1>Performing Post-Build Event...
1>CPack: Create package using NSIS
1>CPack Error: Problem removing toplevel directory:
1>C:/Users/andras/devel/Slicer-3.6/Slicer3-build/_CPack_Packages/win32/N
1>SIS CPack Error: Error when generating package: Slicer3 Project :
1>error PRJ0019: A tool returned an error code from "Performing Post-Build Event..."
1>Project : warning PRJ0018 : The following environment variables were not found:
1>$(ProgramFiles)
1>Build log was saved at "file://c:\Users\andras\devel\Slicer-3.6\Slicer3-build\PACKAGE.dir\Release\BuildLog.htm" [^]
1>PACKAGE - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 273 up-to-date, 0 skipped ==========
No tags attached.
gif Win7FileLockProblem.gif (34,286) 2010-06-03 18:17
https://public.kitware.com/Bug/file/3164/Win7FileLockProblem.gif
gif
Issue History
2010-06-03 18:17Andras Lasso 2New Issue
2010-06-03 18:17Andras Lasso 2File Added: Win7FileLockProblem.gif
2010-06-04 13:06Brad KingStatusnew => assigned
2010-06-04 13:06Brad KingAssigned To => David Cole
2010-06-04 13:08Brad KingNote Added: 0020926
2010-06-04 14:45Brad KingNote Added: 0020927
2010-06-05 11:11Andras Lasso 2Note Added: 0020929
2010-06-07 08:35Brad KingNote Added: 0020930
2010-06-07 08:36Brad KingStatusassigned => closed
2010-06-07 08:36Brad KingResolutionopen => fixed

Notes
(0020926)
Brad King   
2010-06-04 13:08   
Instead of cleaning an existing directory (_CPack_Packages/win32/NSIS) we should create a new randomly-generated name every time (_CPack_Packages/win32/NSIS/957sld). CPack can try to delete old paths but can ignore the failure case because it will generate a fresh name anyway.
(0020927)
Brad King   
2010-06-04 14:45   
As a less-intrusive workaround I've added code to repeat the removal attempt:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fdb5f787 [^]

Hopefully this makes total failure less likely.
(0020929)
Andras Lasso 2   
2010-06-05 11:11   
I've tested the cmake-2.8.1.20100603-g3d1e8-win32 version (compiled & packaged Slicer, repeated 3 times) and it worked perfectly. The file delete now works robustly on my Windows 7 PC!
(0020930)
Brad King   
2010-06-07 08:35   
Great, thanks for testing!