PowerShell / PowerShell

PowerShell for every system!
https://microsoft.com/PowerShell
MIT License
45.54k stars 7.3k forks source link

Install-Package does not support -SkipDependencies #20343

Closed Liturgist closed 1 year ago

Liturgist commented 1 year ago

Prerequisites

Steps to reproduce

PS C:\src> Install-Package -Name mimekit -Source nuget-org-cache -Scope CurrentUser -SkipDependencies
Install-Package: A parameter cannot be found that matches parameter name 'SkipDependencies'.

Expected behavior

Package mimekit would install.

Actual behavior

Package mimekit does not install.

Error details

PS C:\src> Get-Error

Exception             :
    Type              : System.Management.Automation.ParameterBindingException
    Message           : A parameter cannot be found that matches parameter name 'SkipDependencies'.
    ParameterName     : SkipDependencies
    ErrorId           : NamedParameterNotFound
    Line              : 1
    Offset            : 74
    CommandInvocation :
        MyCommand        : Install-Package
        BoundParameters  :
            Comparer : System.OrdinalIgnoreCaseComparer
            Count    : 3
            Keys     :
                Length : 4

                Length : 6

                Length : 5
            Values   :
                Length      : 1
                LongLength  : 1
                Rank        : 1
                SyncRoot    :
                    Length : 7
                IsFixedSize : True
                Count       : 1

                Length      : 1
                LongLength  : 1
                Rank        : 1
                SyncRoot    :
                    Length : 15
                IsFixedSize : True
                Count       : 1

                Length : 11
            SyncRoot :
                Comparer : System.OrdinalIgnoreCaseComparer
                Count    : 3
                Keys     :
                    Length : 4

                    Length : 6

                    Length : 5
                Values   :
                    Length      : 1
                    LongLength  : 1
                    Rank        : 1
                    SyncRoot    :
                        Length : 7
                    IsFixedSize : True
                    Count       : 1

                    Length      : 1
                    LongLength  : 1
                    Rank        : 1
                    SyncRoot    :
                        Length : 15
                    IsFixedSize : True
                    Count       : 1

                    Length : 11
                SyncRoot :
                    Comparer : System.OrdinalIgnoreCaseComparer
                    Count    : 3
                    Keys     :
                        Length : 4

                        Length : 6

                        Length : 5
                    Values   :
                        Length      : 1
                        LongLength  : 1
                        Rank        : 1
                        SyncRoot    :
                            Length : 7
                        IsFixedSize : True
                        Count       : 1

                        Length      : 1
                        LongLength  : 1
                        Rank        : 1
                        SyncRoot    :
                            Length : 15
                        IsFixedSize : True
                        Count       : 1

                        Length : 11
                    SyncRoot :
                        Comparer : System.OrdinalIgnoreCaseComparer
                        Count    : 3
                        Keys     :
                            Length : 4

                            Length : 6

                            Length : 5
                        Values   :
                            Length      : 1
                            LongLength  : 1
                            Rank        : 1
                            SyncRoot    :
                                Length : 7
                            IsFixedSize : True
                            Count       : 1

                            Length      : 1
                            LongLength  : 1
                            Rank        : 1
                            SyncRoot    :
                                Length : 15
                            IsFixedSize : True
                            Count       : 1

                            Length : 11
                        SyncRoot :
                            Comparer : System.OrdinalIgnoreCaseComparer
                            Count    : 3
                            Keys     :
                                Length : 4

                                Length : 6

                                Length : 5
                            Values   :
                                Length      : 1
                                LongLength  : 1
                                Rank        : 1
                                SyncRoot    :
                                    Length : 7
                                IsFixedSize : True
                                Count       : 1

                                Length      : 1
                                LongLength  : 1
                                Rank        : 1
                                SyncRoot    :
                                    Length : 15
                                IsFixedSize : True
                                Count       : 1

                                Length : 11
                            SyncRoot :
                                Comparer : System.OrdinalIgnoreCaseComparer
                                Count    : 3
                                Keys     :
                                    Length : 4

                                    Length : 6

                                    Length : 5
                                Values   :
                                    Length      : 1
                                    LongLength  : 1
                                    Rank        : 1
                                    SyncRoot    : …
                                    IsFixedSize : True
                                    Count       : 1

                                    Length      : 1
                                    LongLength  : 1
                                    Rank        : 1
                                    SyncRoot    : …
                                    IsFixedSize : True
                                    Count       : 1

                                    Length : 11
                                SyncRoot :
                                    Comparer : System.OrdinalIgnoreCaseComparer
                                    Count    : 3
                                    Keys     : …
                                    Values   : …
                                    SyncRoot : …
        ScriptLineNumber : 1
        OffsetInLine     : 1
        HistoryId        : 49
        Line             : Install-Package -Name mimekit -Source nuget-org-cache -Scope CurrentUser -SkipDependencies
        PositionMessage  : At line:1 char:1
                           + Install-Package -Name mimekit -Source nuget-org-cache -Scope CurrentU …
                           + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        InvocationName   : Install-Package
        PipelineLength   : 1
        PipelinePosition : 1
    ErrorRecord       :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : A parameter cannot be found that matches parameter name 'SkipDependencies'.
            HResult : -2146233087
        CategoryInfo          : InvalidArgument: (:) [Install-Package], ParentContainsErrorRecordException
        FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
        InvocationInfo        :
            MyCommand        : Install-Package
            ScriptLineNumber : 1
            OffsetInLine     : 74
            HistoryId        : 49
            Line             : Install-Package -Name mimekit -Source nuget-org-cache -Scope CurrentUser -SkipDependencies
            PositionMessage  : At line:1 char:74
                               + …  mimekit -Source nuget-org-cache -Scope CurrentUser -SkipDependencies
                               +                                                       ~~~~~~~~~~~~~~~~~
            CommandOrigin    : Internal
        ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    TargetSite        :
        Name          : VerifyArgumentsProcessed
        DeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation, Version=7.3.7.500, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Data              : System.Collections.ListDictionaryInternal
    Source            : System.Management.Automation
    HResult           : -2146233087
    StackTrace        :
   at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
   at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
   at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
   at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
   at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[]
pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo          : InvalidArgument: (:) [Install-Package], ParameterBindingException
FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
InvocationInfo        :
    MyCommand        : Install-Package
    ScriptLineNumber : 1
    OffsetInLine     : 74
    HistoryId        : 49
    Line             : Install-Package -Name mimekit -Source nuget-org-cache -Scope CurrentUser -SkipDependencies
    PositionMessage  : At line:1 char:74
                       + …  mimekit -Source nuget-org-cache -Scope CurrentUser -SkipDependencies
                       +                                                       ~~~~~~~~~~~~~~~~~
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

PS C:\src> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.7
PSEdition                      Core
GitCommitId                    7.3.7
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

kilasuit commented 1 year ago

Whilst this is an issue with a cmdlet in a module that is shipped with PowerShell - this is caused by an externally developed module in PackageManagement which is not maintained or developed in this repo and is no longer getting active development as per the readme in it's repo

You may be able to replace use of Install-Package from PackageManagement with commands from PSResourceGet instead, which is currently undergoing active development and is the future replacement for both PackageManagement and PowerShellGet

Liturgist commented 1 year ago

@kilasuit, PowerShellGet does not have an Install-Package command.

Where can I find detailed information regarding the similarities and differences between a 'module', 'script', and 'package'?