Why am I getting "File exists" error in cygwin when trying to remove it?

0

I have a couple of files that I can't remove:

> rm foo
> rm: cannot remove 'foo': File exists

basically I also get the same error if I try to mv the file, chmod it or even if I try to cat it.

To me this error confuses me. I think there may be many valid reasons why you can't do this and that with a file, but the file existing should not be a reason to fail removing it or do the other things.

What is actually going on here? Is there some other windows error that maps to EEXISTS in a confusing way or what?

skyking

Posted 2017-10-12T08:32:34.550

Reputation: 141

1That's a confusing message, alright. Cygwin provides its own version of strace which shows the Windows system calls used to run a command. To get more information on what's happening, you could install it and try running the rm command through that. – Anthony Geoghegan – 2017-10-12T09:11:56.163

@AnthonyGeoghegan Thanks for the tip, it looks like ERROR_FILE_CORRUPT is translated to EEXIST which is confusing at least in this case at least. I wonder what the scenario that was in their mind when they mapped it that way. – skyking – 2017-10-12T09:39:35.437

1That sounds wrong to me - but there may be a good reason for it (e.g., no POSIX equivalent for a corrupted file error code). It might be worth raising the issue on their mailing list to get clarification on it. I'd also suggest that you put your findings into an answer (and accept it) so that it could help others in a similar situation. – Anthony Geoghegan – 2017-10-12T09:57:59.113

No answers