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

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

Closed
agalapovs opened this issue Oct 9, 2014 · 6 comments
Closed

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

agalapovs opened this issue Oct 9, 2014 · 6 comments
Milestone

Comments

@agalapovs
Copy link

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.

@ghost
Copy link

ghost commented May 1, 2015

+1

@abandoned-cocoon
Copy link

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?

@mbodmer
Copy link

mbodmer commented Nov 30, 2015

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

@KUGA2
Copy link

KUGA2 commented Jan 18, 2017

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.

@jhasse
Copy link
Collaborator

jhasse commented Apr 17, 2019

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.

@jhasse jhasse added the windows label Apr 17, 2019
@jhasse jhasse removed this from the 1.10.0 milestone Aug 2, 2019
@jralls
Copy link

jralls commented Jan 31, 2020

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.

mischajonker added a commit to mischajonker/ninja that referenced this issue Sep 13, 2021
remove() deletes both files and directories. On Windows we have to
select the correct function (DeleteFile will yield Permission Denied
when used on a directory)

This fixes the behavior of ninja -t clean in some cases
ninja-build#828
@jhasse jhasse added this to the 1.11.0 milestone Sep 14, 2021
@jhasse jhasse closed this as completed Sep 16, 2021
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

6 participants