Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

@bos
Copy link
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 ../
@bos
Copy link
Contributor Author

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.

@bos
Copy link
Contributor Author

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.

@tibbe
Copy link
Member

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 tibbe closed this as completed May 5, 2014
@RyanGlScott
Copy link
Member

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
Projects
None yet
Development

No branches or pull requests

3 participants