This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Updating to 2.0.0 results in error about PackageManagement update clobbering its own commands #329
Closed
Description
Expected Behavior
That install-module powershellget -force
from an admin prompt works without any errors.
Current Behavior
PowerShellGet isn't updated and I get this error:
09-15 10:35:46 3> Install-Module PowerShellGet -Force
PackageManagement\Install-Package : The following commands are already available on this system:'Find-Package,Install-Package,Uninstall-Package'. This module 'PackageManagement' may override the existing commands. If you still want to install this module 'PackageManagement', use -AllowClobber parameter.
At C:\program files\powershell\6\Modules\PowerShellGet\PSModule.psm1:9491 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Possible Solution
It seems like there should be special case handling of PackageManagement installing (updating) to avoid the clobber error (and having to use -AllowClobber).
Steps to Reproduce (for bugs)
- Install PS Core 6.1 on a clean Windows 10 machine.
- Start PS Core elevated
- Try to
update-module PowerShellGet
update-module : Module 'PowerShellGet' was not installed by using Install-Module, so it cannot be updated.
At line:1 char:1
+ update-module PowerShellGet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PowerShellGet:String) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : ModuleNotInstalledUsingInstallModuleCmdlet,Update-Module
- Try
install-module PowerShellGet
:
WARNING: Version '1.6.7' of module 'PowerShellGet' is already installed at 'C:\program files\powershell\6\Modules\PowerShellGet'. To install version '2.0.0', run Install-Module and add the -Force parameter, this command will install version '2.0.0' side-by-side with version '1.6.7'.
- Ok, try
install-module PowerShellGet -force
:
PackageManagement\Install-Package : The following commands are already available on this system:'Find-Package,Install-Package,Uninstall-Package'. This module 'PackageManagement' may override the existing commands. If you still want to install this module 'PackageManagement', use -AllowClobber parameter.
At C:\program files\powershell\6\Modules\PowerShellGet\PSModule.psm1:9491 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
- Sigh, try
install-module PowerShellGet -force -allowClobber
:
WARNING: The version '1.1.7.2' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications.
OK this is getting frustrating
- Close and re-open PS Core as admin and run
install-module PowerShellGet -force -allowClobber
again:
WARNING: The version '1.1.7.2' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications.
But at least this time 2.0.0 appears to have installed:
> gmo
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.1.4 ClipboardText {Get-ClipboardText, Set-ClipboardText, gcbt, scbt}
Script 1.0.0 DirColors {ConvertFrom-LSColors, ConvertTo-LSColors, Format-Colorize...
Manifest 6.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemPropert...
Manifest 6.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script 1.1.7.2 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script 1.0.0.0 posh-git {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranch...
Script 2.0.0 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script 2.0.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...
Script 1.0.0 ZLocation {Get-ZLocation, Invoke-ZLocation, Pop-ZLocation, Remove-ZL...
Context
I'm just trying to update to PowerShellGet 2.0.0 on PS Core 6.1 GA.
Your Environment
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.1.4 ClipboardText {Get-ClipboardText, Set-ClipboardText, gcbt, scbt}
Script 1.0.0 DirColors {ConvertFrom-LSColors, ConvertTo-LSColors, Format-Colorize...
Manifest 6.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemPropert...
Manifest 6.1.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest 6.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 6.1.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Script 1.1.7.2 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script 1.0.0.0 posh-git {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranch...
Script 2.0.0 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script 2.0.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...
Script 1.0.0 ZLocation {Get-ZLocation, Invoke-ZLocation, Pop-ZLocation, Remove-ZL...
> Get-Module -ListAvailable PowerShellGet,PackageManagement
Directory: C:\Users\Keith\Documents\PowerShell\Modules
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Script 2.0.0 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Fi...
Directory: C:\Program Files\PowerShell\Modules
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Script 2.0.0 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Fi...
Directory: C:\program files\powershell\6\Modules
ModuleType Version Name PSEdition ExportedCommands
---------- ------- ---- --------- ----------------
Script 1.1.7.2 PackageManagement Desk {Find-Package, Get-Package, Get-PackageProvider,...
Script 1.6.7 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Fi...
> Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
NuGet 2.8.5.210 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 2.0.0.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, …
> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
NuGet 2.8.5.210 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 2.0.0.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
PowerShellGet 1.6.7.0