Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to update software using winget upgrade --all: bad optional access #4972

Open
ArtistYay opened this issue Nov 15, 2024 · 9 comments
Open
Assignees
Labels
Command-Upgrade Issue related to WinGet Upgrade Issue-Bug It either shouldn't be doing this or needs an investigation.

Comments

@ArtistYay
Copy link

Brief description of your issue

Running the command winget upgrade --all and I'm getting an error of An unexpected error occurred while executing the command: Bad optional access.

Image

Things I've tried:

  1. winget source reset --force; winget source update
    Image

  2. Manually Add winget.exe to PATH. I saw that I didn't have winget in my environment variable path so I added it with the C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_8.1.19411.0_x64__8wekyb3d8bbwe directory.

  3. I Tried to uninstall and reinstall the App installer but got a grey box.Image

  4. Not sure if this will help but can't find the executable in file explorer.
    Image

  5. Lastly, I tried renaming the pinning database but nothing like that is found in my file explorer.
    Image

System Specs:

winget --version v1.9.25180

Edition: Windows 11 Home
Version: 23H2
OS build: 22631.4460
Experience: Windows Feature Experience Pack 1000.22700.1047.0

Here is my logs -> WinGet-2024-11-15-08-26-37.950.log

I also seen issue #4909 but don't think the issue was resloved.

Steps to reproduce

Run the winget upgrade --all command

Expected behavior

To upgrade the packages.

Actual behavior

Not upgrading the packages.

Environment

`winget --info
Windows Package Manager v1.9.25180
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22631.4460
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.24.25180.0

Winget Directories
-------------------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings                    %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads`
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label Nov 15, 2024
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@denelon denelon added Issue-Bug It either shouldn't be doing this or needs an investigation. Command-Upgrade Issue related to WinGet Upgrade and removed Needs-Triage Issue need to be triaged labels Nov 15, 2024
@denelon
Copy link
Contributor

denelon commented Nov 15, 2024

I don't think I've seen this issue reported before.

It looks like the pinning database isn't getting created if the path is empty.

We'll look into this to see if we can fix it. In the meantime, I've got a couple of ideas to try and see if we can find a workaround.

Try running Repair-WinGetPackageManager -Force -Latest from the Microsoft.WinGet.Client PowerShell module to see if that fixes the issue.

If that doesn't fix it, I'd try adding a pin to one of your packages and then removing the pin.

@florelis
Copy link
Member

This isn't related to the actual problem but I wanted to point a out a couple of things:
 

Manually Add winget.exe to PATH. I saw that I didn't have winget in my environment variable path so I added it with the C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_8.1.19411.0_x64__8wekyb3d8bbwe directory.

You don't need to add that to your PATH, and generally you shouldn't need to touch C:\Program Files\WindowsApps\ directly.
winget and other packaged apps use an App Execution Alias, which creates something similar to a symbolic link to the executable at %LocalAppData%\Microsoft\WindowsApps. That's the one that needs to be on your PATH

(Also, the version number in that path doesn't look right. We don't have a 8.1.19411)

Lastly, I tried renaming the pinning database but nothing like that is found in my file explorer.

The pinning database (and all other winget data) is not in C:\ProgramData\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\ but in %LocalAppData%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\

@ArtistYay
Copy link
Author

@denelon did what you asked and still getting the error. Your right as well, the pinning database isn't getting created.

Image

@JohnMcPMS JohnMcPMS self-assigned this Nov 19, 2024
@JohnMcPMS
Copy link
Member

I think I found the problem. The only workaround is to upgrade one at a time, at least until you have upgraded one of the "conflicting" packages with dependencies.

@JohnMcPMS
Copy link
Member

I should also have mentioned that I'm working on the fix right now and hope to have the PR out soon and the fix published this week.

@JohnMcPMS
Copy link
Member

One more update: You actually should be able to avoid the problem (mostly) with winget upgrade --all --skip-dependencies. That may cause its own issues though if the required dependencies are not already installed.

@JohnMcPMS JohnMcPMS changed the title Trying to update software using winget upgrade --all Trying to update software using winget upgrade --all: bad optional access Nov 19, 2024
JohnMcPMS added a commit that referenced this issue Nov 19, 2024
Likely fix for #4972

## Change
Use `std::optional` overloaded operator to handle all of the comparisons
in `DependencyList::Add`. The operator already properly handles all of
the cases, including treating `std::nullopt` as always less than a
defined value.

Also optimize a few other places around a reference to `MinVersion`.

## Validation
Added a unit test covering the cases where `Add` needs to merge the
minimum version value.
@ArtistYay
Copy link
Author

@JohnMcPMS Looks like the winget upgrade --all --skip-dependencies works! It ran with no issues. I later ran the winget upgrade --all as well and worked as well to.

@sharathbabumr
Copy link

@JohnMcPMS : the command winget upgrade --all --skip-dependencies works well I ran it with absolutely no issues.

JohnMcPMS added a commit to JohnMcPMS/winget-cli that referenced this issue Nov 21, 2024
)

Likely fix for microsoft#4972

## Change
Use `std::optional` overloaded operator to handle all of the comparisons
in `DependencyList::Add`. The operator already properly handles all of
the cases, including treating `std::nullopt` as always less than a
defined value.

Also optimize a few other places around a reference to `MinVersion`.

## Validation
Added a unit test covering the cases where `Add` needs to merge the
minimum version value.
JohnMcPMS added a commit that referenced this issue Nov 22, 2024
[Cherry pick #4987 to 1.9]

Likely fix for #4972

## Change
Use `std::optional` overloaded operator to handle all of the comparisons
in `DependencyList::Add`. The operator already properly handles all of
the cases, including treating `std::nullopt` as always less than a
defined value.

Also optimize a few other places around a reference to `MinVersion`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-Upgrade Issue related to WinGet Upgrade Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

No branches or pull requests

5 participants