winget-cli
winget-cli copied to clipboard
Windows cannot access the folder where the download happens during 'upgrade'
Brief description of your issue
when i try a winget upgrade 'package' for a package that installs in program files, i get the attached error. I am running in standard user mode. I am sure that admin has access to the folder.

Steps to reproduce
type winget upgrade 'package name' wait for the download type in the admin password get the error message
Expected behavior
I expected the program to install properly
Actual behavior
The application errors out and does not install if it requires admin
Environment
Windows Package Manager v1.4.10173
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Desktop v10.0.22621.1265
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.19.10173.0
Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
Links
---------------------------------------------------------------------------
Privacy Statement https://aka.ms/winget-privacy
License Agreement https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
This happens for most applications that require admin. something about not being able to access the network or directory. but the directory has full privileges.

Brief description of your issue
when i try a winget upgrade 'package' for a package that installs in program files, i get the attached error. I am running in standard user mode. I am sure that admin has access to the folder.
Facing the exact same issue.
The problem is with the temp directory winget uses for install.
This is located at %LOCALAPPDATA%\temp\WinGet and simply has insufficient permissions for an elevated permission install.
So effectively the given admin account is unable to read files from this directory.
Unfortunately, it doesn't help to adjust the permissions for this directory manually, because winget resets it during upgrade.
This problem already persists for months now and I've no clue why this hasn't been fixed yet. Actually it should affect many users, if not all uses.
I saw this too. When trying to install "7zip.7zip":
Winget install 7zip.7zip
I got the problem mentioned by the original poster. It seems to be related to the repository and happening with user elevation. If I use this instead:
winget install "7-zip" --source msstore
Then it will install. So, I guess other repositories are buggy
This has been a consistent problem for me and a main reason why I must still rely on other package managers.
I face the exact same issue.
I also face this issue for anything requiring admin. I was trying to install Oracle.Virtualbox but I also tried to upgrade existing packages, and it failed with the same network error.
The problem is with the temp directory winget uses for install. This is located at
%LOCALAPPDATA%\temp\WinGetand simply has insufficient permissions for an elevated permission install. So effectively the given admin account is unable to read files from this directory. Unfortunately, it doesn't help to adjust the permissions for this directory manually, because winget resets it during upgrade.This problem already persists for months now and I've no clue why this hasn't been fixed yet. Actually it should affect many users, if not all uses.
What I can't understand is why it doesn't affect every package that needs admin elevation. Some of the programs I have installed can still be updated via winget, others can't.
@io43 I tried to do what you said, But from the admin command, I get this:
Winget uninstall 7zip.7zip
No installed package found matching input criteria.
I tried with the "Runas" command with different switches: "/profile", "/noprofile", "/env", and no switch at all and I always get that error. I even tried running "cmd" from the start menu as administrator, but still the same result.
From my normal user, the package will be found, but I will get the error from the original poster.
That's why I switched to chocolatey. There I have to run the console as admin as well, but at least this works.
I moved away from winget to scoop because of this specific bug. My work laptop is configured to use a non-admin account for everyday work and occasionally use a different admin account to run stuff elevated.
This bug is already fixed in the 1.5 version. You may download the preview version in the Releases tab and I can confirm that this issue is no longer present.
I can confirm it's working with the preview version (v1.5.1081-preview) 👍
Yes, working well on current preview
cc @denelon Resolved in #2945