Repository navigation
Pin a package #476
Description
Description of the new feature/enhancement
Users should be able to prevent the Windows Package Manager from updating a package (assumes the package doesn't have it's own auto-update).
winget pin <package> and the corollary winget unpin <package>.
This was mentioned by:
Sebastian N. (@megamorf) #120 (comment)
rodalpho #120 (comment)
aetos (@aetos382) #120 (comment)
Kai Mindermann, M.Sc. (@kmindi) #120 (comment)
Proposed technical implementation details (optional)
There should also be a mechanism to display the packages (and the version) that have been "pinned". This might be a function of list or a function of pin. Additionally, if packages are known to self-update (like Visual Studio Code) an additional meta-data entry in the manifest could help users understand when they may not be able to pin a package.
Edit: Clarifying behavior for ambiguity suggested in other Issues.
Pinning should enable users to specify the exact version (likely the default case with no parameters).
It should also allow users to specify what portion of a version should be pinned so bug fixes could be applied, or even minor version bumps.
Note: the syntax below is just suggestive.
Assume the user has installed "Awesome App" version "1.2.3".
winget pin "Awesome App"
This would pin to version 1.2.3 and would not be upgraded when any newer version is released.
winget pin "Awesome App" --version 1.2
This would pin version to anything less than version 1.3. If version 1.2.4 were released this would be a valid upgrade.
winget pin "Awesome App" --version 1
This would pin the version to anything less than version 2. If version 1.2.4 were released this would be a valid upgrade. If version 1.3.0 were released this would also be a valid upgrade.
Additional example per Mats Sibelius (@brainz80)
E.g. Having nodejs-lts version 12.1.1 installed and running winget pin --all nodejs-lts --version 12.x should make it so that when later winget upgrade --all is ran it'd check if there is a update available for nodejs-lts what matches 12.x - if the latest update is e.g 16.1.1, but there is also a 12.1.2 it'd update nodejs-lts to that version.
Activity
megamorf commentedon Jul 1, 2020
From my experience the most common scenario for why you'd want to pin a package version is when there is a known issue with a newer version of that package itself or with one if its dependencies. So on Linux that meant I pinned the docker package because one of its dependencies (containerd) could not be installed.
winget must be able to resolve dependencies (once implemented) for this feature to be really useful since it needs to block the update of all packages that have the pinned package listed in their dependencies.
I also like pinning because it allows me to rely on software that is prone to change a lot (for example when it's early in development) and I can rest easy that it will stay the same unless I explicitly unpin it again.
brunovieira97 commentedon Jul 30, 2020
I don't see it exactly that way. I could simply block an app, let's say NodeJS, of installing updates because I'm developing stuff that is tested only against a specific version of such package. Anyway, there's lots of use cases, specially for devs.
megamorf commentedon Jul 30, 2020
That's what nvm (node version manager) is for ;-) My line of work is DevOps and most of the times this has been necessary was due to issues in operations but your experience may vary.
domoaligato commentedon Jun 30, 2021
I think that this might be related or something need to be put in place to support software versions that are higher than the repo versions.
Here is my example:
I have opted into the Beta versions of Battle.Net
This is before a upgrade.
The Client then opens and updates itself to the latest beta version and shows the same results as before.
Maybe this is just something wrong with the packages and this functionality is not needed, but Discord.Discord , GOG.Galaxy, EpicGames.EpicGamesLauncher all have this issue.
Croydon commentedon Jun 30, 2021
As a note, please don't block pinning of packages that are known to self-update / have own updaters. I'm using package pinning in chocolatey also for packages, which I want to update via another mechanism than chocolatey itself. I think this is a valid use case too.
theodiefenthal commentedon Jul 4, 2021
Two more usecases (well one and a half):
Soitora commentedon Jul 4, 2021
Personally, I'd like to block Python as I got multiple Python installations if it's needed, which it has been in the past for a few niche programs. But it wants to update all of them to latest.
121 remaining items
vrolijken commentedon Jun 9, 2023
A number of "please add a feature to exclude apps from update --all" issues have been closed as a duplicate of this one. I'd like to point out that they may be different things. For instance Microsoft Teams updates itself, but does not update the version number. I do not want to pin Teams at an old version, but I do want to exclude it from the all updates.
Another example is that a number of applications are managed by my organisation. I do not want control over which version they should be, I just know that I should not update them myself.
mdanish-kh commentedon Jun 9, 2023
Friso Vrolijken (@vrolijken) Please take a look at Package Pinning Types. Your request can be catered by making the pins as
Blockingnorahvii commentedon Jun 9, 2023
I made a python script that doesn't require external libraries to help with this. It seems to work. Feedback appreicated.
dschulman-repay commentedon Jul 6, 2023
I'm puzzled by the pinning behavior I'm seeing in WinGet 1.6.1573-preview.
Yesterday, a WinGet package for a nightly build of Node.js was released. I'd prefer to wait for an official release, so added a "gating" pin via
winget pin add --id=OpenJS.NodeJS --version=20.* --force. That appeared to work:But subsequent calls to
winget upgradeproduceThe issue appears to be that WinGet allows that nightly build to be displayed since its version doesn't match the gating
20.*regex. Which makes sense - but what, if any, mechanism is available for the desired "don't bug me with nightly builds" behavior?Or am I missing something here?
florelis commentedon Jul 14, 2023
Dave Schulman (@dschulman-repay) For the specific case of Node.js nightly builds, the nightly builds have been removed from the winget-pkgs repo, so they shouldn't show up anymore. Correct handling of nightly and stable versions would be covered by #147
But the pinning thing is weird. What you expected should have been what happened; gating it to
20.*should have prevented21.0.0-nightly....from showing up onwinget upgrade. It would still show inwinget list, though.winget upgradeshows the latest version winget would try to upgrade to (so it would filter those not matching the pin) butwinget listwould show the latest available even if it's pinned.cobalt2727 commentedon Jul 16, 2023
Currently I'm a big fan of the workaround where I just... don't accept the admin prompt for programs I don't want to attempt an update for.
edit: /s
masterflitzer commentedon Jul 16, 2023
very bad workaround, not every app needs an UAC prompt and the workaround is interactive only, also how can you say big fan when this is a mediocre workaround at best
maksyms commentedon Jul 22, 2023
This is the only workaround that works for me now. Pinning packages (VC Redistributables) - and yet, on
winget upgrade --all, they're still being upgraded.MagicAndre1981 commentedon Jul 24, 2023
looks like you missed the
--blockingparametermaksyms commentedon Jul 24, 2023
MagicAndre1981 Nope, tried that as well. Note that both
--versionand--blockingsimultaneously are not allowed.MagicAndre1981 commentedon Jul 24, 2023
winget pin add --id Mozilla.Thunderbird --blockingworks for me and prevents the accidentally update from 102.13.0 to 115 which has a new UI which I don't want 🤔 🤷♂️tawissus commentedon Apr 6, 2024
Is it possible to exclude a current version?
There is currently a problem with RustDesk, for example. An older version is being delivered there (1.2.3 overwrites 1.2.3-1).
helmesjo commentedon Nov 6, 2024
Just for future reference:
I think, instead of inventing extra flags, that it would be better to pick a syntax that covers it all (so instead of flags, the internal machinery just parse the constraint). See
build2version constraints for an example of something that works very well.Examples:
Pinning could still exist, but above scheme would be more in line how the CLI is excepted to work. Looking at other package managers you often want this possibility at the time of install instead of pinning it (which I assume is) globally.