PowerShell / PowerShellGet

This module provide functions used with PowerShellGet v3 to provide compatibility with scripts expecting PowerShellGet v2
MIT License
49 stars 13 forks source link

GetSteppablePipeline RuntimeException #58

Open TezzKF opened 7 months ago

TezzKF commented 7 months ago

Prerequisites

Steps to reproduce

Date 20-11-2023 following the documentation: git clone https://github.com/PowerShell/PowerShellGet cd path/to/PowerShellGet (substituted with my own path) Import-Module src/PowerShellGet -Force

Getting issues with New_Alias: The alias is not allowed, because an alias with the name 'fimo' already exists. Solving issue by changing alias to 'fimoN' (same with other aliasses)

running command again: Import-Module src/PowerShellGet -Force (no feedback this time, does not know whether is succesful or not)

running command: Install-Module -Name PowerShellGet -RequiredVersion 2.2.5 -Allowclobber -Force -Debug -Verbose Getting the next error: error

Expected behavior

PowerShellGet installed in version 2.2.5

Actual behavior

RuntimeException

Error details

Exception calling "GetSteppablePipeline" with "0" argument(s): "The expression after '&' in a pipeline element produced
 an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."
At C:\xxx\Downloads\PowerShellGet\src\PowerShellGet.psm1:1148 char:13
+             $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RuntimeException

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.19041.3570
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3570
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

PowerShell version 5.1

Visuals

No response

TezzKF commented 7 months ago

Mine main course was following https://learn.microsoft.com/en-us/powershell/gallery/powershellget/update-powershell-51?view=powershellget-3.x to upgrade PowershellGet under PowerShell-5.1

When I run Install-Module PowerShellGet -AllowClobber -Force I get error Exception in Test-MicrosoftCertificate function: Unable to find type [Microsoft.PowerShell.Commands.PowerShellGet.Win32Helpers]. So mine second approach was the one i described above.

skaempfer commented 6 months ago

Same error here when trying to use version 3.0.23-beta23 of PowerShellGet via PowerShellGet installation in PS Core.

Reproduction:

  1. Install-Module PowerShellGet -version "3.0.23-beta23" -AllowPrerelease -Repository PSGallery
  2. Open new PowerShell
  3. Import-Module -Name PowerShellGet
  4. Get-Module lists PowerShellGet in version 3.0.23-beta23
  5. Get-PSRepository and Register-PSRepository throw the following error:
ParentContainsErrorRecordException: Exception calling "GetSteppablePipeline" with "0" argument(s): "The expression after '&' in a pipeline element produced
an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."

Environment

Name                           Value
----                           -----
PSVersion                      7.3.10
PSEdition                      Core
GitCommitId                    7.3.10
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
LarryWisherMan commented 3 months ago

The issue seems related to $WrappedCmd and it being null when trying to call commands from the Microsoft.PowerShell.PSResourceGet module.

A workaround I found was installing this module

Install-Module -Name Microsoft.PowerShell.PSResourceGet

Not sure if this being phased out - or if the dependency is needed before the prerelease module is used.

deadlydog commented 3 months ago

I had this same issue. Unfortunately, I couldn't even install PSResourceGet because the Install-Module command was broken with the Exception calling "GetSteppablePipeline" with "0" argument(s) error. I ended up having to view the module paths with $env:PSModulePath and I found the newer PowerShellGet module at C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\3.0.23, so I deleted that directory.

Once I deleted the new PowerShellGet version I was able to use Install-Module -Name Microsoft.PowerShell.PSResourceGet and have been updating my scripts to use Install-PSResource instead of Install-Module.

So the root issue seems to be that Install-Module is broken in PowerShellGet v3.0.23 and the workaround is to either use PowerShellGet 2.2.5 (the last stable version), or update to use Microsoft.PowerShell.PSResourceGet (which is the future way to manage modules anyhow).

I'll note too that I still have PowerShellGet v3.0.12 installed on some machines and it works fine, so it seems this bug was introduced sometime after that prerelease version.

anamnavi commented 2 months ago

@TezzKF @deadlydog thanks for reporting this issue. We plan to fix this before GA of the module.