Open sdwheeler opened 7 years ago
I have hit this same issue with two of my modules (PureStoragePowerShellSDK and PureStoragePowerShellToolkit).
If users have scripts that require modules at X version, And update module replaces the available version then some script written long ago might break.
Maybe there should be a Get-OutdatedModule
that could be piped to remove-module. At least the user intended to get rid of versions that way.
Similar problem solutions I've seen would be npm prune. Perhaps a Clear-module
could inspect all available modules RequiredModules Version tree and remove only modules that aren't found/older but semver compatible.
But that would only maintain other declared modules, user scripts might break on removal of older modules. And you'd be trusting authors concept of semver.
@JKeithB - We need a way to uninstall a module and all its dependencies. Adding that functionality to Uninstall-Module should be very simple. I wrote the following function to uninstall a module and its dependencies.
function uninstall-modwithdependencies
param(
[string]$module,
[string]$version
)
'Creating list of dependencies...'
$depmods = Find-Module $module -RequiredVersion $version |
select -exp dependencies |
select @{l='name';e={$_.name}},@{l='ver';e={$_.requiredversion}}
foreach ($mod in $depmods) {
'Uninstalling {0}' -f $mod.name
uninstall-module $mod.name -RequiredVersion $mod.ver
}
Uninstall-Module $module -RequiredVersion $version
}
@SydneyhSmith / @SteveL-MSFT if this issue is not completed before PSGet 3.0 GA will it be a breaking change?
@ThomasNieto for 3.0 we are maintaining the behavior of Update, to install the latest version, and not delete older versions... since this has always been the behavior of PowerShellGet this will not be a change...in the future we may address this feature request by adding a parameter to the Update cmdlet that specifies older versions of the module should be uninstalled
| Assert-Duplicate -Near -Fuzzy $_ #581
@ThomasNieto for 3.0 we are maintaining the behavior of Update, to install the latest version, and not delete older versions... since this has always been the behavior of PowerShellGet this will not be a change...in the future we may address this feature request by adding a parameter to the Update cmdlet that specifies older versions of the module should be uninstalled
Would it be possible to change this so that Update-Module does update by default, and install side-by-side when a parameter is added?
I'd argue that the expected behaviour of any update mechanism is to replace the old version with the new one, so this should also be the default for PSGet 3
@danielniccoli have you read the discussion of that over in #581?
Update-Module only installs a newer version. It does not remove the previous version. This is no different that using Install-Module except that it checks the current installed version an searches for a newer version. That search functionality would be better implemented as a -Update parameter for Install-Module.
Expected Behavior
Update-Module should replace the current version with a new version. Not install the new version side-by-side with the old version.
Possible Solutions
Context
Using the verb
Update
is confusing to customers. They expect the cmdlet to update what they have not install side-by-side. Also, the cmdlet reference does not explain this behavior.We see this a lot with Azure PowerShell. They release a new version every month. After a few months you can have several versions installed taking up a lot of space.
Your Environment