[3.0] Installation of Carbon Module asks about clobbering existing commands

Create issue
Issue #220 open
Roger Qiu created an issue

See:

 > Install-Module -Name Carbon -Force
PackageManagement\Install-Package : The following commands are already available on this
system:'Get-FileShare,Get-ScheduledTask,Set-EnvironmentVariable,Get-Certificate'. This module 'Carbon' may
override the existing commands. If you still want to install this module 'Carbon', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.2.0\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Pa
   ckage], Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerSh
   ell.PackageManagement.Cmdlets.InstallPackage

Some of these commands already exist natively in Windows 10. See: https://technet.microsoft.com/en-us/library/mt774137.aspx and https://technet.microsoft.com/en-us/library/hh848632.aspx

Should these commands be renamed?

Comments (7)

  1. Aaron Jensen repo owner

    Unfortunately, I can't rename anything in Carbon. It will break backwards-comparability, which makes it less likely that existing users will upgrade. Carbon was around way before any of these cmdlets ever existed. Please use the -AllowClobber switch to Install-Module. I know this isn't a great answer. I wish PowerShell had better name spacing and separation of module commands. I recommend that whenever you import Carbon, you specify a prefix, e.g. 'C', so that you can use commands between different modules.

  2. Aaron Jensen repo owner

    I'm doing some investigating and experimentation on possible workarounds and fixes for this issue. Can you tell me what modules have those commands?

    Get-Command -Name 'Get-FileShare','Get-ScheduledTask','Set-EnvironmentVariable','Get-Certificate'
    

    I want to know if they are built in commands or come from other third-party modules.

  3. Aaron Jensen repo owner
    • changed status to open

    Re-opening pending investigation and experimentation around possible fixes and/or workarounds.

  4. Matt McElreath

    I submitted issue #224 which is related to this one. The Get-WindowsFeature cmdlet gets hosed unless you explicitly import the Servermanager module. This worked fine however up to WMF 5.0. It didn't break until 5.1 was installed.

  5. Aaron Jensen repo owner

    This is something that I'll address in Carbon 3.0 because the fix will potentially break backwards compatibility. PowerShell looks in the FunctionsToExport metadata in a module's manifest to see what commands that module exports when determining if any commands will be clobbered. There is no way to dynamically create this list, so I'll have to remove the commands. If anyone is using auto-loading to auto-load Carbon when using those functions, that change will break scripts. There are no plans for releasing Carbon 3.0. I push out major versions when I've accrued enough breaking changes to warrant it.

  6. Log in to comment