cabal clean: Error while removing dist/: dist/setup: removeDirectory: unsatisified constraints (Directory not empty) #296

Closed
bos opened this Issue May 24, 2012 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

bos commented May 24, 2012

(Imported from Trac #303, reported by @simonmar on 2008-06-23)

cabal clean has a problem on Windows and Unix with NFS that causes it to fail when using a custom Setup.hs. The problem is that we compile Setup.hs to dist/setup/setup, and then invoke dist/setup/setup clean which is supposed to remove the whole of the dist tree, including the running binary. This causes problems on Windows where running binaries can't be deleted, and also on NFS where deleting the running binary leaves a .nfs file behind, preventing the parent directory from being deleted.

> cabal clean -v
Creating dist/setup (and its parents)
dist/setup/setup clean --verbose=2 --distpref=dist
cleaning...
Error while removing dist/: dist/setup: removeDirectory: unsatisified constraints (Directory not empty)
> ls -lr dist
total 36
-rw-rw-r-- 1 simonmar GHC 13069 2008-06-23 11:34 setup-config
drwxrwxr-x 2 simonmar GHC  4096 2008-06-23 11:34 setup/
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:32 build/
~/darcs/ghc-paths > ls -lra dist
total 52
-rw-rw-r-- 1 simonmar GHC 13069 2008-06-23 11:34 setup-config
drwxrwxr-x 2 simonmar GHC  4096 2008-06-23 11:34 setup/
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:32 build/
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:32 ../
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:34 ./
~/darcs/ghc-paths > ls -lRa dist
dist:
total 52
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:34 ./
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:32 ../
drwxrwxr-x 4 simonmar GHC  4096 2008-06-23 11:32 build/
drwxrwxr-x 2 simonmar GHC  4096 2008-06-23 11:34 setup/
-rw-rw-r-- 1 simonmar GHC 13069 2008-06-23 11:34 setup-config
dist/build:
total 52
drwxrwxr-x 4 simonmar GHC 4096 2008-06-23 11:32 ./
drwxrwxr-x 4 simonmar GHC 4096 2008-06-23 11:34 ../
drwxrwxr-x 2 simonmar GHC 4096 2008-06-23 11:32 autogen/
drwxrwxr-x 2 simonmar GHC 4096 2008-06-23 11:32 GHC/
-rw-rw-r-- 1 simonmar GHC 3657 2008-06-23 11:32 HSghc-paths-0.1.o
-rw-rw-r-- 1 simonmar GHC 4404 2008-06-23 11:32 libHSghc-paths-0.1.a
dist/build/autogen:
total 24
drwxrwxr-x 2 simonmar GHC 4096 2008-06-23 11:32 ./
drwxrwxr-x 4 simonmar GHC 4096 2008-06-23 11:32 ../
-rw------- 1 simonmar GHC  990 2008-06-23 11:32 Paths_ghc_paths.hs
dist/build/GHC:
total 32
drwxrwxr-x 2 simonmar GHC 4096 2008-06-23 11:32 ./
drwxrwxr-x 4 simonmar GHC 4096 2008-06-23 11:32 ../
-rw-rw-r-- 1 simonmar GHC  895 2008-06-23 11:32 Paths.hi
-rw-rw-r-- 1 simonmar GHC 3824 2008-06-23 11:32 Paths.o
dist/setup:
total 16
drwxrwxr-x 2 simonmar GHC 4096 2008-06-23 11:34 ./
drwxrwxr-x 4 simonmar GHC 4096 2008-06-23 11:34 ../
Contributor

bos commented May 24, 2012

(Imported comment by @dcoutts on 2008-06-23)

The problem here is with custom Setup.hs scripts that might want to do something for clean. A solution would be to be able to ask the Setup.hs to clean anything custom and let the calling tool (ie cabal-install) recursively delete the dist directory. On windows and nfs it's not easy for a program to delete itself and the directory it is running from.

On the other hand, this kind of cooperation does not work well with custom build systems. See CustomBuildInterface.

Contributor

bos commented May 24, 2012

(Imported comment by Phyx on 2009-03-09)

Isn't a simple solution to never let Setup delete it's own exe? Worse case if using the setup script clean leaves an exe, if cabal was used it can remove the exe left behind.

If it's a big deal to not leave anything at all the hackish way around it would be to inject some shellscript into a running program like explorer and have it delete the exe.

Owner

tibbe commented May 5, 2014

Closing as there's been no activity in years.

We're cleaning up the bug tracker to make it useful again and are thus closing bugs that haven't seen any activity in a long time. Please re-open (or file a new bug) if the problem reappears.

tibbe closed this May 5, 2014

Member

RyanGlScott commented Aug 5, 2014

This bug (which also falls under the scope of issue #1863) still happens to me on Windows with cabal-install-1.20.0.3 and Cabal-1.20.0.2. Having a cabal project with a Custom build-type will yield the following error when cabal clean is run:

[1 of 1] Compiling Main             ( dist\setup\setup.hs, dist\setup\Main.o )
Linking .\dist\setup\setup.exe ...
cleaning...
Error while removing dist/: DeleteFile "dist\\setup\\setup.exe": permission denied (Access is denied.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment