chocolatey / chocolatey/docs

Add recommendations for detecting out-of-band installed applications in package install scripts

Open
#406 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
MDX
Stars
223
Forks
248
Avg merge
1d 26m
Merged PRs (30d)
4

Description

## Is Your Feature Request Related To A Problem? Please describe.

Somewhat related to the FAQ issue described in the [Automatic Sync documentation](https://docs.chocolatey.org/en-us/features/package-synchronization/automatic-sync#sync-is-not-tracking-upgrades-to-applications).

Essentially, it's not perfectly possible even in the Pro edition to keep package versions up to date with the installed software versions due to a lack of standardization and the proliferation of self-updating packages.

Some packages on the Community Repository currently have checks in place to skip the actual downloading/running of their installers if they detect the installed software version is already up to date. One example would be the `googlechrome` package. It would be good if that is provided as a recommendation, as it will help users avoid unnecessary reinstalls or errors when doing `choco upgrade all` for example.

## Describe The Solution. Why is it needed?

We should add some recommendations to the [packaging documentation](https://docs.chocolatey.org/en-us/create/create-packages) that maintainers creating or updating their packages, especially those handling software that is capable of auto-updating itself, include some mechanism to detect whether the software was updated out-of-band. In this case, if the software is detected as being already up to date, the install script can simply `return` early instead of re-running the installer and potentially modifying a perfectly good installation.

I would also suggest packages check if the package is being installed with `-f` / `--force` which appears to be passed into the process environment as `$env:chocolateyForce` (see environment code [here](https://github.com/chocolatey/choco/blob/ababf506acde28b6dd24b3183af1e28a8ef6ebe1/src/chocolatey/infrastructure.app/configuration/EnvironmentSettings.cs#L130)) -- though an argument could be made that a lot of these aren't documented and probably should be, but that's a separate issue, just mentioning this here as this one is particularly relevant.

My thought is if users do `choco install --force` then the package should look to detect already-installed versions and do a full reinstall in that case. I don't know if that's a sensible suggestion for every use case, so I'm happy to discuss on that point for sure.

## Additional Context.

## Related Issues

N/A

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.