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

Unable to upgrade a package if a dependency only contains pre-release package versions, or if package no longer exists on available sources #3292

Closed
5 tasks done
AdmiringWorm opened this issue Aug 3, 2023 · 3 comments · Fixed by #3293
Assignees
Milestone

Comments

@AdmiringWorm
Copy link
Member

Checklist

  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.
  • I confirm I am using official, and not unofficial, or modified, Chocolatey products.

What You Are Seeing?

When I have installed an older version of a package, and there is a package installed that have a dependency on this package but only has pre-releases available, if I then later try to upgrade the dependent package it will throw a null reference exception preventing the upgrading.

image

What is Expected?

An upgrade of a package should succeed, even if a parent package is missing or only contain pre-releases on the configured sources.

How Did You Get This To Happen?

  1. Install the package chocolatey-core.extension version 1.3.3.
  2. Install latest version of pre-release package firefox-dev
  3. Upgrade chocolatey-core.extension to latest version.

System Details

  • Operating System: Windows 10 / Windows Server 2022
  • Windows PowerShell version: PSv5
  • Chocolatey CLI Version: Chocolatey CLI 2.2.0
  • Chocolatey Licensed Extension version: N/A
  • Chocolatey License type: N/A
  • Terminal/Emulator: PowerShell

Installed Packages

chocolatey 2.2.0
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.3.3
chocolatey-windowsupdate.extension 1.0.5
firefox-dev 117.0.2-beta
KB2919355 1.0.20160915
KB2919442 1.0.20160915
KB3118401 1.0.5

Output Log

https://gist.github.com/AdmiringWorm/91744e460c3acd5d4e26c9327093105d

Additional Context

No response

@AdmiringWorm AdmiringWorm self-assigned this Aug 3, 2023
AdmiringWorm added a commit to AdmiringWorm/choco that referenced this issue Aug 3, 2023
These changes makes sure that we pass along any pre-release flag
when there is a pre-release package that is a parent of one of the
packages that we are installing, and to verify that the results is not
null before we attempt to use it.

This ensures that pre-release only packages can be found when we
look up the parent, and if by some reason the package can not be
found we do not throw an undesired null exception in this case.
@gep13 gep13 added this to the 2.2.2 milestone Aug 3, 2023
@gep13 gep13 changed the title Unable to upgrade package if parent only contain pre-releases Unable to upgrade a package if the package parent only contains pre-release package versions Aug 4, 2023
gep13 pushed a commit to AdmiringWorm/choco that referenced this issue Aug 4, 2023
These changes makes sure that we pass along any pre-release flag
when there is a pre-release package that is a parent of one of the
packages that we are installing, and to verify that the results is not
null before we attempt to use it.

This ensures that pre-release only packages can be found when we
look up the parent, and if by some reason the package can not be
found we do not throw an undesired null exception in this case.
gep13 pushed a commit to AdmiringWorm/choco that referenced this issue Aug 4, 2023
These changes makes sure that we pass along any pre-release flag
when there is a pre-release package that is a parent of one of the
packages that we are installing, and to verify that the results is not
null before we attempt to use it.

This ensures that pre-release only packages can be found when we
look up the parent, and if by some reason the package can not be
found we do not throw an undesired null exception in this case.
gep13 added a commit that referenced this issue Aug 4, 2023
…ade-package-if-p

(#3292) Ensure pre-release flag is used for parent lookup
@gep13 gep13 added 4 - Done and removed 3 - Review labels Aug 4, 2023
@gep13 gep13 closed this as completed Aug 4, 2023
gep13 added a commit that referenced this issue Aug 8, 2023
* hotfix/2.2.2:
  (maint) Remove unnecessary line break
  (#3292) Ensure pre-release flag is used for parent lookup
gep13 added a commit that referenced this issue Aug 8, 2023
* master:
  (maint) Remove unnecessary line break
  (#3292) Ensure pre-release flag is used for parent lookup
@choco-bot
Copy link

🎉 This issue has been resolved in version 2.2.2 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

@gep13 gep13 changed the title Unable to upgrade a package if the package parent only contains pre-release package versions Unable to upgrade a package if a dependency only contains pre-release package versions, or if package no longer exists on available sources Aug 8, 2023
@AdmiringWorm
Copy link
Member Author

AdmiringWorm commented Aug 8, 2023

Do note that this bug also affects installed packages that does not exist on your sources, but the dependency of the package exist and you are attempting to upgrade it.

As an example.

  • You have package X and Y installed
  • Package Y depends on package X
  • Package X exist on your sources, but package Y does not exist.
  • You attempt to upgrade package X using choco upgrade x
  • This will fail with the same exception.

To work around this issue for the above either ensure that all packages exist on one or more sources configured, or uninstall package y before attempting to upgrade package x.

This can affect upgrading Chocolatey CLI itself as well, as there are quite a few existing packages that have a dependency on chocolatey.

EDIT: This was also fixed as part of fixing this issue.

@TheCakeIsNaOH
Copy link
Member

If you run into this issue upgrading Chocolatey CLI itself, the easiest way I found to determine the problematic package is to use choco upgrade chocolatey --verbose and look at the last query made before the error shows up, and that should be the package that needs to be temporarily removed. (or redo multiple times if there are multiple issues). In my case, it was cleanup-desktop-shortcuts.hook

There may be a better way to do this, but long term, a command to see the dependency graph would be very useful: #1125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants