Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-Variable already available error when installing #8

Open
aloysiustany opened this issue Apr 7, 2017 · 6 comments
Open

Get-Variable already available error when installing #8

aloysiustany opened this issue Apr 7, 2017 · 6 comments
Assignees

Comments

@aloysiustany
Copy link

aloysiustany commented Apr 7, 2017

Hi,

I am getting the following error when installing Octopus-Cmdlets.

PackageManagement\Install-Package : A command with name 'Get-Variable' is already available on this
system. This module 'Octopus-Cmdlets' may override the existing commands. If you still want to install
this module 'Octopus-Cmdlets', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21

  • ... $null = PackageManagement\Install-Package @PSBoundParameters
  •                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Ins
      tall-Package], Exception
    • FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.
      PowerShell.PackageManagement.Cmdlets.InstallPackage
@indented-automation
Copy link

This also affects profile scripts which use Get-Variable / Remove-Variable. The prefix implementation in PowerShell is pretty flakey, what you've written should work.

This bug appears to be fixed in PowerShell 6 (alpha 18). However, it is present in 5.1 which is going to be as much as can be expected in most places.

Would you consider hard-coding the prefix?

@Swoogan
Copy link
Owner

Swoogan commented Jul 12, 2017

Are you able to override it when importing?

Import-Module [-Global] [-Prefix <String>]

I'm reluctant to hard code it because that would also limit people's options when there is a clash.

@indented-automation
Copy link

indented-automation commented Jul 12, 2017 via email

@Swoogan Swoogan self-assigned this Oct 17, 2017
@Swoogan
Copy link
Owner

Swoogan commented Sep 25, 2018

What is the "autoloader"? Is there some way to blacklist this module from it and then manually invoke Import-Module from your profile?

@rpresser
Copy link

rpresser commented May 8, 2019

Is there any progress on this? The error happens while doing Install-Module, not just while doing Import-Module, so I'm not sure how a prefix will help.

@Swoogan
Copy link
Owner

Swoogan commented May 8, 2019

Hello. It turns out this is a known bug with PowerShell: PowerShell/PowerShell#2590

You can read an excellent description of the problem by another module author: https://pkisharp.github.io/ACMESharp-docs/Why-AllowClobber.html

For the time being, I recommend using the -allowClobber flag when installing and the default prefix of Octo will be added when importing the module (unless overridden by the -Prefix flag)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants