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

Help errors with PowerShell 7.4.1: Get-Help: ForwardHelpTargetName cannot refer to the function itself. #62

Open marcinsmialek opened 5 months ago

marcinsmialek commented 5 months ago

Prerequisites

Steps to reproduce

Get-Help Find-Module
# Get-Help: ForwardHelpTargetName cannot refer to the function itself.

It throws error in PowerShell Core 7.4.1 and in PowerShell Windows 5.1
The same problem exists for the other commands in PowerShellGet module

This is the ForwardHelpTargetName - CircularDependencyInHelpForwarding check:
https://github.com/PowerShell/PowerShell/blob/79639822c4302f9d3e46f14db50e246bac7c5e15/src/System.Management.Automation/help/CommandHelpProvider.cs#L450-L454

The latest Find-Module help target forwarding:
https://github.com/PowerShell/PowerShellGet/blob/fe34ca3eb6e1db2b78d2aae0465cd2165a3d50b6/src/PowerShellGet.psm1#L560-L563

Expected behavior

Get-Help Remove-Module

NAME
    Remove-Module

SYNOPSIS
    Removes modules from the current session.
...

Actual behavior

Get-Help Find-Module
Get-Help: ForwardHelpTargetName cannot refer to the function itself.

Error details

Get-Error

Exception             :
    Type        : System.Management.Automation.PSInvalidOperationException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : ForwardHelpTargetName cannot refer to the function itself.
            HResult : -2146233087
        CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : InvalidOperation
    TargetSite  :
        Name          : MoveNext
        DeclaringType : System.Management.Automation.CommandHelpProvider+<ExactMatchHelp>d__12, System.Management.Autom
ation, Version=7.4.1.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message     : ForwardHelpTargetName cannot refer to the function itself.
    Source      : System.Management.Automation
    HResult     : -2146233079
    StackTrace  :
   at System.Management.Automation.CommandHelpProvider.ExactMatchHelp(HelpRequest helpRequest)+MoveNext()
   at System.Management.Automation.CommandHelpProvider.ProcessForwardedHelp(HelpInfo helpInfo, HelpRequest helpRequest)
+MoveNext()
   at System.Management.Automation.HelpSystem.ForwardHelp(HelpInfo helpInfo, HelpRequest helpRequest)+MoveNext()
   at System.Management.Automation.HelpSystem.ExactMatchHelp(HelpRequest helpRequest)+MoveNext()
   at System.Management.Automation.HelpSystem.DoGetHelp(HelpRequest helpRequest)+MoveNext()
   at Microsoft.PowerShell.Commands.GetHelpCommand.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : InvalidOperation: (:) [Get-Help], PSInvalidOperationException
FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.GetHelpCommand
InvocationInfo        :
    MyCommand        : Get-Help
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 44
    Line             : Get-Help Find-Module
    Statement        : Get-Help Find-Module
    PositionMessage  : At line:1 char:1
                       + Get-Help Find-Module
                       + ~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Get-Help
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

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

Version

3.0.23-beta23

Visuals

image