35

Whenever I switch between my branch (Li) to the master branch I get the following message:

Deletion of directory 'sys/console/api' failed. Should I try again? (y/n)

Anyone knows how do I get rid of this message? I think that in the past I tried to delete this directory by mistake and now I'm stuck with this error message.

Zoe
  • 27,060
  • 21
  • 118
  • 148
user429400
  • 3,145
  • 12
  • 49
  • 68

3 Answers3

35

This error message comes from this patch (in compat/mingw.c), and this one (also in compat/mingw.c).
It usually means your directory is "busy", or isn't empty (but contains only private files, ie non-versioned files).

So make sure that, when checking out a branch, you don't have a running process making your specific directory "busy".

Ted M Young helpfully comments:

Another definition of "busy" is that it's your current directory!
It seems safest to do a cd to the root directory and then change directories to avoid this error.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 11
    Another definition of "busy" is that it's your current directory! It seems safest to do a `cd` to the root directory and then change directories to avoid this error. – Ted M. Young Oct 19 '12 at 01:19
  • @TedM.Young good point. I have included your comment in the answer for more visibility. – VonC Oct 19 '12 at 05:27
  • I went from scratching my head straight to a facepalm. Thanks @TedM.Young and VonC – ray Aug 11 '13 at 01:47
  • Could you please explain in words what it is the piece of code you have written in your answer does? (I am in no mood to try to interpret it and find out what it does, besides, this is a git question; I'm not even sure everyone who reads your answer knows how to interpret C code) In what way is it related to the rest of the answer? – HelloGoodbye Jan 05 '14 at 15:03
  • @HelloGoodbye Sure. I have removed the code (now part of the Git [`compat/mingw.c` source code](https://github.com/git/git/blob/44484662d83de2ae98d04738ec43d4dea1f859a8/compat/mingw.c#L276-L279)). That code was just to illustrate where the error message "`Deletion of directory '...' failed. Should I try again? (y/n)`" comes from (the message that the OP mentions in the question). From a user's perspective, all you need to do is making sure your directory you want to delete isn't busy. – VonC Jan 05 '14 at 16:56
  • I had my file opened in Sublime Text (my IDE.) Closing that out fixed the issue. – NessDan Dec 01 '14 at 19:19
5

I just had to quit out of VS Code to get the error to go away

1

As with all the blocking Folder/File things, use Process Explorer → Ctrl + F → type the folder name. See the vscode, notepad++ or other app that is using it, kill the process.

Volodymyr Kotylo
  • 483
  • 5
  • 11