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.
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.
-
We start by attempting to install
glab
, and note that that the following error occurs. -
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 runchoco install KB3063858 --ignore-dependencies
to ignore the dependency failure. -
Now that we have
KB3063858
installed, we attempt to runchoco 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
. -
Now with
KB2919355
installed we continue withchoco install KB2999226
. Again we make note of the next package (KB2919442
) and install this package while ignoring dependencies:choco install KB2999226 --ignore-dependencies
. -
Now with
KB2999226
installed, we attempt to runchoco install KB2919442
. We see that this one is actually already installed, so we attempt to installglab
again. Whenglab
fails to install, we make note of the next package missing in our chain:chocolatey-windowsupdate.extension
. -
We install this in the same way as before (
choco install chocolatey-windowsupdate.extension
, thenchoco install chocolatey-windowsupdate.extension --ignore-dependencies
). -
We install the next package (
KB3033929
) and note that it did not have any dependency failures. -
So, we attempt our install of
glab
once more. Thankfully, we are able to install it with no dependency errors.