Search code examples
javadependenciespackagechocolatey

Manage Chocolatey package dependencies


I am new to Chocolatey and I installed zulu as an alternative to Oracle Java (choco install zulu). Then I installed an app requiring Java choco install pdfsam.install, which installed Oracle JRE as a dependency. I thought to be smart and, later, I tried to choco uninstall javaruntime. But I got an error "because 'pdfsam.install 3.3.2' depends on it.".

By reading the commands' help, I saw the install switch --ignore-dependencies and the uninstall switch --force-dependencies and --force.
The first two are clear. So I could:

choco uninstall pdfsam.install --force-dependencies
choco install pdfsam.install --ignore-dependencies

As regards --force, it is unclear what it does and its use is kind of discouraged:

--force
Force - force the behaviour. Do not use force during normal operation - it subverts some of the smart behaviour for commands.

It could mean uninstall a package even if another package depends on it. (who knows?)

My questions are:

  1. What if I run a routine choco upgrade all to removed dependencies?
  2. My app is just an example. Beyond JRE an app might have other non-ignorable dependencies. Can I selectively ignore dependencies?

Solution

  • When you first install, you will want to use --ignore-depdendencies (or on an upgrade specified explicitly), then turn on useRememberedArgumentsForUpgrades feature. Then when you upgrade, it may continue to ignore dependencies (as long as that is not one of the switches that is ignored).

    If it is not one you find is ignored, file a ticket at https://github.com/chocolatey/choco/issues/new to have us add it as an enhancement.