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)

Most upvoted comments

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 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)

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 /T

I have one more question: anyone who saw this issue isn’t MSFT? 😆

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 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)

This worked for me! Thank you @Erijoda !

I just ran into this myself.

---------------------------
Visual Studio Code
---------------------------
There was an error while Opening file handle: "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-amd.js":

Failed to create file handle: Access is denied.



Please verify there are no Visual Studio Code processes still executing.
---------------------------
Retry   Cancel   
---------------------------
❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-amd.js"
C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-amd.js BUILTIN\Administrators:(I)(F)
                                                                                                      BUILTIN\Users:(I)(RX)
                                                                                                      NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                      NT AUTHORITY\SYSTEM:(I)(F)

Successfully processed 1 files; Failed processing 0 files

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code"
C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code NTDEV\raines:(F)
                                                               CREATOR OWNER:(OI)(CI)(IO)(F)
                                                               BUILTIN\Users:(OI)(CI)(RX)
                                                               NT AUTHORITY\Authenticated Users:(OI)(CI)(RX)
                                                               BUILTIN\Administrators:(OI)(CI)(F)
                                                               NT AUTHORITY\SYSTEM:(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\resources"
C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\resources NTDEV\raines:(I)(F)
                                                                         CREATOR OWNER:(I)(OI)(CI)(IO)(F)
                                                                         BUILTIN\Users:(I)(OI)(CI)(RX)
                                                                         NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(RX)
                                                                         BUILTIN\Administrators:(I)(OI)(CI)(F)
                                                                         NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\resources\app"
C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\resources\app NTDEV\raines:(I)(F)
                                                                             CREATOR OWNER:(I)(OI)(CI)(IO)(F)
                                                                             BUILTIN\Users:(I)(OI)(CI)(RX)
                                                                             NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(RX)
                                                                             BUILTIN\Administrators:(I)(OI)(CI)(F)
                                                                             NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\resources\app\out"
C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\resources\app\out BUILTIN\Administrators:(I)(F)
                                                                                 CREATOR OWNER:(I)(OI)(CI)(IO)(F)
                                                                                 BUILTIN\Users:(I)(OI)(CI)(RX)
                                                                                 NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(RX)
                                                                                 BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
                                                                                 NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\*"
C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-amd.js BUILTIN\Administrators:(I)(F)
                                                                                                      BUILTIN\Users:(I)(RX)
                                                                                                      NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                      NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-fork.js BUILTIN\Administrators:(I)(F)
                                                                                                       BUILTIN\Users:(I)(RX)
                                                                                                       NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                       NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-node.js BUILTIN\Administrators:(I)(F)
                                                                                                       BUILTIN\Users:(I)(RX)
                                                                                                       NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                       NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-window.js BUILTIN\Administrators:(I)(F)
                                                                                                         BUILTIN\Users:(I)(RX)
                                                                                                         NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                         NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap.js BUILTIN\Administrators:(I)(F)
                                                                                                  BUILTIN\Users:(I)(RX)
                                                                                                  NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                  NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js BUILTIN\Administrators:(I)(F)
                                                                                            BUILTIN\Users:(I)(RX)
                                                                                            NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                            NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\main.js BUILTIN\Administrators:(I)(F)
                                                                                             BUILTIN\Users:(I)(RX)
                                                                                             NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                             NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\nls.metadata.json BUILTIN\Administrators:(I)(F)
                                                                                                       BUILTIN\Users:(I)(RX)
                                                                                                       NT AUTHORITY\Authenticated Users:(I)(RX)
                                                                                                       NT AUTHORITY\SYSTEM:(I)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\vs BUILTIN\Administrators:(I)(F)
                                                                                        CREATOR OWNER:(I)(OI)(CI)(IO)(F)
                                                                                        BUILTIN\Users:(I)(OI)(CI)(RX)
                                                                                        NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(RX)
                                                                                        BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
                                                                                        NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)

C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\vscode-dts BUILTIN\Administrators:(I)(F)
                                                                                                CREATOR OWNER:(I)(OI)(CI)(IO)(F)
                                                                                                BUILTIN\Users:(I)(OI)(CI)(RX)
                                                                                                NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(RX)
                                                                                                BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)
                                                                                                NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)

Successfully processed 10 files; Failed processing 0 files

I applied Full control to my user (NTDEV\raines) with

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\*" /grant NTDEV\raines:F
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-amd.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-fork.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-node.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap-window.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\bootstrap.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\cli.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\main.js
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\nls.metadata.json
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\vs
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\out\\vscode-dts
Successfully processed 10 files; Failed processing 0 files

and got to the new error

---------------------------
Visual Studio Code
---------------------------
There was an error while Opening file handle: "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\extensions\\bat\\language-configuration.json":

Failed to create file handle: Access is denied.



Please verify there are no Visual Studio Code processes still executing.
---------------------------
Retry   Cancel   
---------------------------

A reset did not help

❯ icacls "C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\extensions\\bat\\language-configuration.json" /reset
processed file: C:\\Users\\raines\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\extensions\\bat\\language-configuration.json
Successfully processed 1 files; Failed processing 0 files

So I did icacls "%LOCALAPPDATA%\Programs\Microsoft VS Code" /grant "%USERDOMAIN%\%USERNAME%":F /T to 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 /T from an admin command prompt fixed it for me.

Add me to the list of Microsoft people who are experiencing this that you can ping 😅.

  • Do you usually OR have you recently ran VS Code as Administrator, using the User Setup?
    • No, I’ve never intentionally invoked something as Admin on this machine
  • When you right click the VS Code installation folder (%localappdata%\Programs\Microsoft VS Code), select Properties, Security, does CREATOR OWNER show up in the list? If you click Advanced, who is listed as the Owner?
    • CREATOR OWNER is there
    • The owner is my own domain account (redmond\ryanca)
    • Probably relevant: Only the SYSTEM user and Adminstrators Group has Modify privileges on this folder
  • Is your machine domain joined?
    • Yes

Something like that worked once for me, but with the next update the problem occurred again. It’s a workaround. Something is changing the ACLs, and seems to be happening only for VSCode. Other user-installed programs haven’t exhibited this problem.

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 😜)

  • Do you usually OR have you recently ran VS Code as Administrator, using the User Setup?

Yes I sometimes run VS Code elevated when I develop PowerShell scripts that #requires -runasadministrator

I presume an update took place upon exiting such an instance.

  • When you right click the VS Code installation folder (%localappdata%\Programs\Microsoft VS Code), select Properties, Security, does CREATOR OWNER show up in the list? If you click Advanced, who is listed as the Owner?

Yes, CREATOR OWNER is 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).

  • Is your machine domain joined?

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:

There was an error while Opening file handle:
"C:\\Users\\...\\AppData\\Local\\Programs\\Microsoft VS Code\\policies\\Code.admx":

Failed to create file handle: Access is denied.

Please verify there are not Visual Studio Code process still executing.

Verification:

  1. Install the user setup of VS Code
  2. Verify on the Advanced Security Settings of the %localappdata%\Programs\Microsoft VS Code Insiders directory that your user has Full control access to This folder, subfolders and files and not just This folder only. Example:

image

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 OWNER identity isn’t working as we expected.

Broken:

image


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:

image


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.

  • Do you usually OR have you recently ran VS Code as Administrator, using the User Setup?

No

  • When you right click the VS Code installation folder (%localappdata%\Programs\Microsoft VS Code), select Properties, .Security, does CREATOR OWNER show up in the list? If you click Advanced, who is listed as the Owner?

Me, but if I look at perms for a file that fails, it is <Local Machine>\Administrators

  • Is your machine domain joined?

Yes, to REDMOND.

  1. I haven’t ever run VS Code as an admin
  2. I’ve already run the workaround, but here’s my info: Creator Owner does show up. There is no “Owner”. I am listed as having Full Control for This Folder Only. Creator Owner has Full Control for Subfolders & files only
  3. My account is AAD joined but my machine is not Domain Joined. I’m MSFT-internal as well. Feel free to reach out

image

  • Do you usually OR have you recently ran VS Code as Administrator, using the User Setup?

Not always but for one repo I work in I run VS code as admin.

  • When you right click the VS Code installation folder (%localappdata%\Programs\Microsoft VS Code), select Properties, Security, does CREATOR OWNER show up in the list? If you click Advanced, who is listed as the Owner?

Yes, CREATOR OWNER is there; my domain account is listed as the owner.

  • Is your machine domain joined?

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.

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?

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.

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.

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)