简体   繁体   中英

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?

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.

When you force-uninstall a dependency project, this dependency will be re-installed once the depending project gets updated.

as example:

a package 'foo' depends on a package 'bar' you decide to install foo, therefore bar gets installed too.

now you can force-uninstall bar, but foo still stays installed (choco uninstall bar --force). as soon as you update foo, iff it still has the dependency on bar, bar will get installed again.

sample command sequence:

choco install foo

  • foo and bar get installed

choco uninstall bar

  • bar won't uninstall and print a message foo depends on it

choco uninstall bar --force

  • forces bar to uninstall (if foo still works correctly or not depends on the package, no way to tell for some unknown package)

choco upgrade foo

  • this will upgrade foo (if a newer version exists) and ensures all dependencies are met - therefore bar will be installed again

I've put together a gist with the required nuspecs and the output for this example: https://gist.github.com/mwallner/b10bcd6ccd1f7b3d65a56a06c8c8aa0a

as for your second question, I don't know if it's possible to selectively ignore dependecies, maybe ferventcoder can help here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM