Dependency Troubleshooting in Chocolatey CLI

Dependency Troubleshooting in Chocolatey CLI

Installation and Upgrade Commands Fail for Many Seemingly Unrelated Packages

Due to the way dependency resolution works, packages with dependencies can occasionally trigger undesirable behavior. When this happens, you will often be presented with both warnings and errors. The most important information will be in the errors, and not the warnings.

When you encounter these errors, it is recommended to start with the package name mentioned in the error, and attempt to install it. Repeat this process with any other failing dependencies until they’re all installed.

In a previous livestream we demoed some of the dependency issues you may experience.

Example 1 - Upgrade All Fails to Upgrade One or More Packages

This will sometimes be encountered with meta-packages, such as obs-studio which takes an exact-version dependency on obs-studio.install. When running choco upgrade all it will attempt to upgrade every installed package. Any packages which fail to install may be retried as part of a later dependency chain. For example, obs-studio.install may be upgraded, fail, and then later be tried again as part of the dependency chain for obs-studio itself. As a result, Chocolatey CLI’s packages may be in an inconsistent state. This is typically characterized by a dependency resolution error message when performing package operations:

Unable to resolve dependencies. 'obs-studio.install 29.0.2' is not compatible with 'obs-studio 29.1.1 constraint: obs-studio.install (>= 29.1.1)'.

This is normally resolved by upgrading the affected dependency. In this example, you would run choco upgrade obs-studio.install to resolve the issue.

The following scenario illustrates what can happen during an upgrade all where a dependency fails to install. In this example, obs-studio installs, but obs-studio.install fails. Due to the dependency version range specified by obs-studio, the version of obs-studio.install that remains installed (due to the upgrade failure) does not satisfy the dependency requirement.

To resolve the issue, we run choco upgrade obs-studio.install to get the correct dependency version installed. For packages that have a specific version dependency, add the --version option and specify the exact version to install.

Partial output from choco upgrade all, showing that obs-studio.install is attempted and failed

Continued output from choco upgrade all, showing that obs-studio metapackage is installed and subsequently re-attempts the upgrade to obs-studio.install which again fails, followed by a dependency resolution error in the next package and failing a seemingly unrelated package installation

Example 2 - Installing a Package Fails Due to Existing Missing Dependencies

WARNING

This example deals with multiple missing dependencies, and installs them while ignoring dependencies. You will need to ensure you’re installing the correct versions required for your dependencies.

The following scenario illustrates what can happen during an install where multiple existing packages have dependencies that are not currently met. In this example, glab is attempting to be installed, but a number of KB packages are missing from the Chocolatey lib directory.

  1. We start by attempting to install glab, and note that that the following error occurs.

    Output from choco install glab where it fails to resolve dependency 'KB306858'

  2. To resolve the issue, we first run choco install KB3063858 to install the first identified package. We note that this fails to install, so we make note of the package it couldn’t find (KB2919355) and we run choco install KB3063858 --ignore-dependencies to ignore the dependency failure.

    Output from choco install KB306858 where it fails to resolve dependency 'KB2919355'

  3. Now that we have KB3063858 installed, we attempt to run choco install KB2919355 to install the next identified package. Again we make note of the next package (KB2999226) and install this package while ignoring dependencies: choco install KB2919355 --ignore-dependencies.

    Output from choco install KB2919355 where it fails to resolve dependency 'KB2999226'

  4. Now with KB2919355 installed we continue with choco install KB2999226. Again we make note of the next package (KB2919442) and install this package while ignoring dependencies: choco install KB2999226 --ignore-dependencies.

    Output from choco install KB2999226 where it fails to resolve dependency 'KB2919442'

  5. Now with KB2999226 installed, we attempt to run choco install KB2919442. We see that this one is actually already installed, so we attempt to install glab again. When glab fails to install, we make note of the next package missing in our chain: chocolatey-windowsupdate.extension.

    Output from choco install KB2919442 where it is already installed. Following output is from choco install glab where it fails to resolve dependency 'chocolatey-windowsupdate.extension'

  6. We install this in the same way as before (choco install chocolatey-windowsupdate.extension, then choco install chocolatey-windowsupdate.extension --ignore-dependencies).

    Output from choco install chocolatey-windowsupdate.extension where it fails to resolve dependency 'KB3033929'

  7. We install the next package (KB3033929) and note that it did not have any dependency failures.

    Output from choco install KB3033929 where it installs with no dependency failures

  8. So, we attempt our install of glab once more. Thankfully, we are able to install it with no dependency errors.

    Output from choco install glab where it finally installs