ninja: error: remove(someDirectory) Permission denied. Windows

Created on 9 Oct 2014  ·  6Comments  ·  Source: ninja-build/ninja

After running "ninja -t clean" got "Permission denied" while deleting a folder.

MSDN describe stdio.h remove() as function for deleting files (not directories), on the other hand Linux man pages describe it as function for deleting files and folders. Could be a platform specific problem.

Calling _rmdir() (http://msdn.microsoft.com/en-us/library/wt8es881.aspx) do the trick.

bug windows

Most helpful comment

CMakeLists.txt
Issue is still present in 1.7.2 on Windows & Linux.

I added a CMake project that will throw this error on ninja clean (i cant code ninja files).
Note: it works with Make or VS generators.

All 6 comments

+1

On linux directories are only removed when they're empty. Can the behaviour be changed to recursive removal? Or maybe give the buildscript an opportunity to do clean up before -t clean tries to remove() the directory?

Same issue here.
Directory was generated by rule created from CMake add_custom_command()

ninja clean
[1/1] Cleaning all built files...
FAILED: /usr/bin/ninja -t clean
ninja: error: remove(mydirectory): Directory not empty

CMakeLists.txt
Issue is still present in 1.7.2 on Windows & Linux.

I added a CMake project that will throw this error on ninja clean (i cant code ninja files).
Note: it works with Make or VS generators.

On linux directories are only removed when they're empty. Can the behaviour be changed to recursive removal?

Would be a pretty big change and people might lose their files. See #1334 btw.

Let's keep this issue about the Windows-only "Permission denied" error though.

Microsoft's documentation for remove says that it "sets errno either to EACCES to indicate that the path specifies a read-only file, specifies a directory, or the file is open...", so that explains what's going on. It doesn't matter if the directory is empty, one simply can't call remove on a directory if using msvcrt.

Was this page helpful?
0 / 5 - 0 ratings