OneGet / oneget

PackageManagement (aka OneGet) is a package manager for Windows
MIT License
2.38k stars 190 forks source link

Change -Force not to overwrite existing module #452

Closed edyoung closed 4 years ago

edyoung commented 5 years ago

The -Force parameter in PowerShellGet and PackageManagement does too many different things:

This change removes the last case, because 99% of the time it is not what you want - I believe it's very unusual for the module to be corrupted on disk and really need to be redownloaded and reinstalled, but we end up doing it because the other uses of -Force are much more frequently required. Many scripts and install instructions specify -Force, which leads to slow re-downloads and re-installs.

Instead, this makes it so that if you already have exactly the correct version of a module installed and you want to refresh it, you have to use -ForceReinstall.

This change is only to Install-Package. If we're OK with this we can make the corresponding change to Install-Module.

This doesn't fully address the issues with the number of different flags to Install-Module (See https://github.com/PowerShell/PowerShellGet/issues/234) but I think it helps, despite adding yet another flag,, because -Force can be used without being a 'bad citizen'. -ForceReinstall is specific enough to the 'clean up this weird mess' scenario that it shouldn't need to be added to scripts.

It could be argued this is a breaking change, but I think the cases where people are surprised and annoyed by having -Force reinstall everything outweigh the cases where people really need that to happen.

edyoung commented 5 years ago

comments? @jianyunt @alerickson @jaykul

alerickson commented 5 years ago

This approach sounds good to me. @SydneyhSmith and I had been talking about approaching the -Force issue by adding a flag to separate out functionality.

I wonder if having -ForceReinstall also include the behavior of -Force would help with the number of flags issue. So -ForceReinstall would essentially have the current behavior of -Force and -Force would have pared down behavior.

Lastly, is the PowerShellGet submodule intentionally added back?

edyoung commented 5 years ago

FYI @joeyaiello @SteveL-MSFT

ThomasNieto commented 5 years ago

Why is this change being made to PackageManagement instead of the PowerShellGet provider? If I'm reading the change correctly this will add a -ForceReinstall parameter to all package provider parameter sets. Is that correct? If so, it will cause confusion for other package providers where reinstall is not a valid use-case. Adding -ForceReinstall as a DynamicOption in PowerShellGet would be a better change.