vscode: Can't Install local user update due to `\\bin` folder being used by another process

image

There was an error while deleting a directory: %LOCALAPPDATA%\Programs\Microsoft VS Code\bin: the process cannot access the file because it is being used by another process…

  • VSCode Version: 1.2.7.2 (user setup)
  • OS Version: Windows 10

Steps to Reproduce:

  1. when an update is available, click Install Update

Does this issue occur when all extensions are disabled?: cannot try this because installation is disabled/destroyed due to incomplete setup

Workaround: will go back to system installs instead of local user installs.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 37
  • Comments: 97 (8 by maintainers)

Most upvoted comments

OK. I was able to repro this in @sergiusignacius’s machine. Weirdly enough, it repros 100% of the time when Skype for Business is running. It doesn’t repro when Skype for Business isn’t running.

Any of you guys have Skype for Business?

Investigating…

I found what was causing it by more research, Have a look at antivirus protection software you may have and look for ransomware protection or exploit protection and temporarily disable them. As in my case, it was locking the folders to make sure viruses could not change or delete folders! All good now, hope it helps others!

Same issue here.

I’m not even able to delete %LOCALAPPDATA%\Programs\Microsoft VS Code\bin manually 😕

Closing Outlook fixed it for me.

I confirm that when Skype was active then the update was failing leaving the user with no installation of VS Code (Insiders in my case). I confirm that terminating the Skype task from the task manager and doing the update works.

I agree with @euij , a failed tentative update shouldn’t leave the system with no installation of VS Code forcing one to download again the app from the website. These two steps should be decoupled and be able to deal differently.

Turning off Malware Bytes seems to solve this error as recommended by @81mark

Run into this issue several times recently, I don’t have Skype for Business installed, but have Skype app installed from Windows 10 Store.

Process Explorer shows %LOCALAPPDATA%\Programs\Microsoft VS Code\bin is used by system process.

I found the following skype processes in Task Manager:

image

Terminate the first two didn’t help, until terminate the last one: SkypeBridge.exe, Process Explorer shows no process is using %LOCALAPPDATA%\Programs\Microsoft VS Code\bin anymore, then hit retry, VS Code successfully upgraded.

Then reopen Skype app, Process Explorer shows %LOCALAPPDATA%\Programs\Microsoft VS Code\bin is used by system process again, terminate SkypeBridge.exe in Task Manger, recheck in Process Explorer, no more processes using bin.

It might be the virus scanner in my case as well, but this is an EVERY install/update PITA for me, too. For me … at least for this morning’s update … it’s the resources folder …

Capture

Capture1

… and the log file indicates …

Dec 17 07:43:41.512 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\bin" (attempt 1)
Dec 17 07:43:41.514 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\locales" (attempt 1)
Dec 17 07:43:41.515 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 1)
Dec 17 07:43:41.693 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 2)
Dec 17 07:43:41.901 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 3)
Dec 17 07:43:42.361 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 4)
Dec 17 07:43:43.162 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 5)
Dec 17 07:43:44.425 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 6)
Dec 17 07:43:46.242 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 7)
Dec 17 07:43:48.699 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 8)
Dec 17 07:43:51.906 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 9)
Dec 17 07:43:55.961 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 10)
Dec 17 07:44:00.964 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 11)
Dec 17 07:44:05.600 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 1)
Dec 17 07:44:05.666 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 2)
Dec 17 07:44:05.871 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 3)
Dec 17 07:44:06.335 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 4)
Dec 17 07:44:07.146 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 5)
Dec 17 07:44:08.404 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 6)
Dec 17 07:44:10.219 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 7)
Dec 17 07:44:12.679 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 8)
Dec 17 07:44:15.895 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 9)
Dec 17 07:44:19.948 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 10)
Dec 17 07:44:24.956 INFO Delete directory recursively: "C:\\Program Files\\Microsoft VS Code\\resources" (attempt 11)
Dec 17 07:44:48.448 ERRO Access is denied. (os error 5)

I really, really wish a permanent fix could be made to the installer process to resolve this once and for all. 😩

This happens to me every time I close VS Code- it starts to update, fails, and then uninstalls VS Code. I have none of the previous programs mentioned that may interfere, and am on a Windows 10

As a workaround, feel free to disable background updates: "update.enableWindowsBackgroundUpdates": false. You’ll still get updates, just not in the background.

Just want to say that there are actually two different problems here (but only tracked by this issue).

  1. Update fails.
  2. Failure of update leaves the system with no VSCode.

One could definitely hide the second problem by making sure that the update never fails. But that is probably not the right solution and I suspect that there should be another issue tracking the second problem.

If you shutdown Skype for Business, does update work?

It works!

Though I had to kill Skype for Business from the task manager as quitting wasn’t enough.

Having same issue every time VS Code gets an update. It tries to auto-update, fails, and corrupts itself and forces me to do a full manual uninstall/reinstall every time. Extremely frustrating.

[SOLVED] I had same issue, but with ‘\resources’ folder. What I did to solve was install IObit Unlocker Software and when the error happen, I use the IObit to unlock & delete the folder and than I “Retry” the update process. After this, another issue appears, but now says “can’t rename ‘code.exe’ file”, so I used IObit again to rename the ‘code.exe’ to ‘code.exe’ (same name, I don’t know why) and “Retry” again. Finally it’s works! Updated succesfully.

Shutting down f.lux solved this issue for me.

Killing Skype works for me

I have this error msg. I shutdown all Skype process and this work!

I was unable to update VS Code this morning and exiting f.lux (https://justgetflux.com/) allowed VS Code to update.

I have no Skype, Skype for Business or Teams open, but still can’t have bin removed.

Any of you guys have Skype for Business?

I do

I don’t know what happened. But when I was re-installing after the code failed to install I choose install a system instead of user and that fixed the issue

wow @81mark, thanks for your advice. It actually worked for my machine !!. I tried different methods above but could not solve the issue. I turned off malware byte ransomware protection and exploit protection and it worked!

This is super frustrating… why hasn’t anyone mentioned “Citrix Workspace” ???!!! 😃

My Windows Process Explorer, like some other people have observed, displays only “System” as the process that owns the file handle to VS Code folder/files. That doesn’t help!

Through trial-and-error, it appears it’s Citrix Workspace. After I shutdown that application, I can delete the files/folder C:\Users\xxx\AppData\Local\Programs\Microsoft VS Code.

I was able to update after first closing Outlook. Looking at all the comments, seems office products are somehow blocking the process.

the new Skype powered by Electron (since Windows 10 1809)

I wasn’t aware Skype moved to Electron (my company moved to Slack), but there are other apps like f.lux that aren’t Electron. The problem people have had seems to mostly be resolved by closing UWP apps.

Also, as another counterpoint, I have Slack installed as a “native” Electron app, installed normally (not from the store). It’s never caused this vscode issue. It’s Electron, but not UWP, but I’ve had UWP apps cause this locked file problem in vscode.

Personally I haven’t seen the issue at all since updating to Windows 1903

Moreover, it seems that when the failure happens, the update program doesn’t roll back the changes. I have to reinstall VSCode to the same location for continued usage.

Don’t have f.lux and skype. Just outlook and OneDrive. Killed both and I keep having the same problems. Any idea?? This is very annoying

image

This is very annoying.

Killing Skype did not work for me, however shutting down OneDrive did the trick.

Wow. I’ve had this problem for well over a year and can verify that closing f.lux (per @cbenard) on my laptop finally resolved this update issue for me.

Addendum: I noticed the same behavior with 1password - i.e. automatic updates of 1password.com failed because a file was being used by ‘another process’. Closing f.lux resolved that issue as well - so this problem sounds more like an issue with f.lux or programs like f.lux.

I’ve always had this issue on this Win10 install.

  1. Disabled update.enableWindowsBackgroundUpdates. Did not work.
  2. Checked for updates and did interactive install. Code.exe is locked.
  3. Closed Skype. Did not work.
  4. Terminated SkypeApp.exe in task manager. Did not work.
  5. Closed f.lux per @TrustMeICan and @shikharsg. Worked. WTF? Whose fault is this and how could having f.lux open make Code.exe get locked by System?

I was unable to update VS Code this morning and exiting f.lux (https://justgetflux.com/) allowed VS Code to update.

I confirm that when Skype was active then the update was failing leaving the user with no installation of VS Code (Insiders in my case). I confirm that terminating the Skype task from the task manager and doing the update works.

I agree with @euij , a failed tentative update shouldn’t leave the system with no installation of VS Code forcing one to download again the app from the website. These two steps should be decoupled and be able to deal differently.

I have f.lux installed, but I managed to update VS code finally after force quitting all Skype-related processes in Task Manager. (I don’t use Skype myself, but I haven’t removed it yet)

I have the same problem. Quit or kill Skype for Business not working.

@sergiusignacius Can reliably reproduce this. Will check with him asap.