vscode: Unable to Update VS Code
Issue Type: Bug
When checking for updates, receive prompt saying the following:
“C:\Users\myusername\AppData\Local\Programs\Microsoft VS Code_\chrome_100_percent.pak An error occurred while trying to create a file in the destination directory: Access is denied”
Available options are:
- Try again
- Skip this file
- Cancel installation.
First two options immediately bring prompt the error again, cancel installation suppresses it until auto-update re-attempts the installation.
Error occurs when running as administrator as well.
VS Code version: Code 1.66.1 (8dfae7a5cd50421d10cd99cb873990460525a898, 2022-04-06T14:50:12.141Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No
System Info
| Item | Value |
|---|---|
| CPUs | AMD Ryzen 9 3900X 12-Core Processor (24 x 3800) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.95GB (22.02GB free) |
| Process Argv | –crash-reporter-id 117dd477-59c8-4487-9ba4-aff765032dc6 |
| Screen Reader | no |
| VM | 0% |
Extensions (1)
| Extension | Author (truncated) | Version |
|---|---|---|
| prettier-vscode | esb | 9.5.0 |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
pythonvsnew555:30457759
vscscmwlcmt:30465135
cppdebugcf:30466690
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 15
- Comments: 57 (18 by maintainers)
Seems the permissions were borked on my install.
I was able to fix it by changing the permissions.
If you have administrator access with your user then you should be able to fix it with these steps:
Step 1) Open CMD.EXE as administrator (with your user)
Step 2) Run:
takeown /F "%LOCALAPPDATA%\Programs\Microsoft VS Code" /R /D YStep 3) Run:
icacls "%LOCALAPPDATA%\Programs\Microsoft VS Code" /inheritance:r /remove "NT SERVICE\TrustedInstaller" /grant:r "%USERDOMAIN%\%USERNAME%":(F) /grant:r "CREATOR OWNER":(OI)(CI)(IO)(F) /grant:r "BUILTIN\Users":(OI)(CI)(RX) /grant:r "NT AUTHORITY\Authenticated Users":(OI)(CI)(RX) /grant:r "BUILTIN\Administrators":(OI)(CI)(F) /grant:r "NT AUTHORITY\SYSTEM":(OI)(CI)(F)If you don’t have administrator then the easiest way to fix would be to have someone with administrator change the owner of folder, subfolder and files in %LOCALAPPDATA%\Programs\Microsoft VS Code, using Windows Explorer’s Properties > Security > Advanced. Once you are the owner you can run the command in Step 3 without administrator.
confirmed that running this from an admin cmd prompt fixed the issue
icacls "%LOCALAPPDATA%\Programs\Microsoft VS Code" /grant "%USERDOMAIN%\%USERNAME%":F /TI have one more question: anyone who saw this issue isn’t MSFT? 😆
This worked for me! Thank you @Erijoda !
I just ran into this myself.
I applied Full control to my user (
NTDEV\raines) withand got to the new error
A
resetdid not helpSo I did
icacls "%LOCALAPPDATA%\Programs\Microsoft VS Code" /grant "%USERDOMAIN%\%USERNAME%":F /Tto do the whole directory. That appears to have worked, and is hopefully a bit less invasive than the full replacement above.Running
icacls "%LOCALAPPDATA%\Programs\Microsoft VS Code" /grant "%USERDOMAIN%\%USERNAME%":F /Tfrom an admin command prompt fixed it for me.Add me to the list of Microsoft people who are experiencing this that you can ping 😅.
I just installed another successful update (1.69.0) without any workarounds (not even running it as admin). I think the issue may have been fixed in one of the most recent versions of VS Code.
(not a Microsoft user 😜)
Yes I sometimes run VS Code elevated when I develop PowerShell scripts that
#requires -runasadministratorI presume an update took place upon exiting such an instance.
Yes,
CREATOR OWNERis present.The owner is my MSA, which is a member of the local Administrators group (but I might have changed that during earlier troubleshooting of the issue).
Nope.
There are various workarounds posted in the thread (thanks!). Can someone on the VS Code team weigh in on which one we should be applying?
I am hitting a slightly different error. The same was reported in #150287 but then closed as duplicate of this issue:
Verification:
%localappdata%\Programs\Microsoft VS Code Insidersdirectory that your user hasFull controlaccess toThis folder, subfolders and filesand not justThis folder only. Example:Hi all, sorry for the delay here. I got something for you.
The problem, as some people pointed out, is related to the permissions left behind once the Setup finishes installing VS Code. Namely, the
CREATOR OWNERidentity isn’t working as we expected.Broken:
By setting the correct permissions for the current user, we should be able to create a good model upfront. I’ve created a build with that fix and ran extensive testing including with usernames with spaces and/or non-ASCII characters.
Fixed:
If you currently hit this issue, I’d appreciate it if you could download the following Insiders build, install it and show me your Advanced Security Settings dialog, so I can confirm things work fine in your setup?
💾 Download Windows x64 Insiders User Setup
I just updated to 1.68.1, and it worked fine this time!
@joaomoreno joaomoreno, MSFT-internal here.
No
Me, but if I look at perms for a file that fails, it is
<Local Machine>\AdministratorsYes, to REDMOND.
Not always but for one repo I work in I run VS code as admin.
Yes,
CREATOR OWNERis there; my domain account is listed as the owner.Yes, AAD joined.
@joaomoreno I’m MSFT-internal so feel free to ping me on Teams if you want to inspect my repro machine directly.
From what I can see, this issue is planned to be fixed in the next update
I run into this with every update. It started to happen in April. I’m logged into Win10 as Admin.
I have to give the VSCode dir all the permissions I can to get it to complete, but the permissions get reverted by the next update, so must be done all over again.
If I cancel the update, it attempts to roll back the changes but leaves me with a corrupt installation and the same missing module error as posted above when trying to launch VSCode. So I think there’s a separate issue with the roll back not working.
To fix the missing module error, reinstalling VSCode works, but after that it still gives the permissions error at next update.
My experience is that this doesn’t solve the issue: once the permissions have become incorrect, it’s no longer possible to upgrade from a non-elevated instance. Updating from an elevated instance is a mere workaround.
Just fyi - #150287 was closed as duplicate of this issue, but actually that problem seems different and is solved by simply running vscode as admin and then updating.
This fixed my issue as well. Thanks @Erijoda
Step 1) Open CMD.EXE as administrator (with your user)
Step 2) Run: takeown /F “%LOCALAPPDATA%\Programs\Microsoft VS Code” /R /D Y
Step 3) Run: icacls “%LOCALAPPDATA%\Programs\Microsoft VS Code” /inheritance:r /remove “NT SERVICE\TrustedInstaller” /grant:r “%USERDOMAIN%%USERNAME%”:(F) /grant:r “CREATOR OWNER”:(OI)(CI)(IO)(F) /grant:r “BUILTIN\Users”:(OI)(CI)(RX) /grant:r “NT AUTHORITY\Authenticated Users”:(OI)(CI)(RX) /grant:r “BUILTIN\Administrators”:(OI)(CI)(F) /grant:r “NT AUTHORITY\SYSTEM”:(OI)(CI)(F)