X Tutup
Skip to content

Update-Help does not work with partial locale #18021

@dkaszews

Description

@dkaszews

Prerequisites

Steps to reproduce

Update-Help does not work if the provided locale is a partial match (i.e. parent) of the available one. This means that if en-US is available, you have to provide exactly en-US and cannot just do en. I believe this is a bug for 2 reasons:

  1. It Makes Sense™ that if user says "I want to use English locale", they mean "Any English variant will do", not "I want to use English not associated with any country".
  2. Update-Help with implicit locale has mechanism to fall back to parents. That is, if you don't provide explicit -UICulture, it uses the system, e.g. en-GB, then if that fails it tries en. The described bug means that fallbacks will always fail, unless the module uses exactly locale en without any country suffix, which they never do.

This can be fixed by changing string.Equals to string.Contains or some other function in UpdatableHelpInfo.IsCultureSupported.

Expected behavior

> Update-Help -Module 'Microsoft.PowerShell.Core' -SourcePath 'assets' -Force -UICulture 'en-US'
> Update-Help -Module 'Microsoft.PowerShell.Core' -SourcePath 'assets' -Force -UICulture 'en'
> # No error reported means success

Actual behavior

> Update-Help -Module 'Microsoft.PowerShell.Core' -SourcePath 'assets' -Force -UICulture 'en-US'
> Update-Help -Module 'Microsoft.PowerShell.Core' -SourcePath 'assets' -Force -UICulture 'en'
Update-Help: Failed to update Help for the module(s) 'Microsoft.PowerShell.Core' with UI culture(s) {en} : Unable to retrieve the HelpInfo XML file for UI culture en. Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again..
English-US help content is available and can be installed using: Update-Help -UICulture en-US.

Error details

Type        : System.Management.Automation.ActionPreferenceStopException
ErrorRecord :
    Exception             :
        Type    : System.Exception
        Message : Failed to update Help for the module(s) 'Microsoft.PowerShell.Core' with UI culture(s) {en} : Unable to retrieve the HelpInfo XML file for UI culture en. Make sure the HelpInfoUri property
in the module manifest is valid or check your network connection and then try the command again..
                  English-US help content is available and can be installed using: Update-Help -UICulture en-US.
        HResult : -2146233088
    CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exception
    FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpCommand
    InvocationInfo        :
        MyCommand        : Update-Help
        ScriptLineNumber : 1
        OffsetInLine     : 1
        HistoryId        : 38
        Line             : Update-Help -Module 'Microsoft.PowerShell.Core' -SourcePath 'assets' -Force -ErrorAction Stop -Scope 'CurrentUser' -UICulture 'en'
        PositionMessage  : At line:1 char:1
                           + Update-Help -Module 'Microsoft.PowerShell.Core' -SourcePath 'assets'  …
                           + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        InvocationName   : Update-Help
        CommandOrigin    : Internal
    ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    PipelineIterationInfo :



TargetSite  :
    Name          : Invoke
    DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    MemberType    : Method
    Module        : System.Management.Automation.dll
Message     : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Failed to update Help for the module(s) 'Microsoft.PowerShell.Core' with
UI culture(s) {en} : Unable to retrieve the HelpInfo XML file for UI culture en. Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the command
again..
              English-US help content is available and can be installed using: Update-Help -UICulture en-US.
Data        : System.Collections.ListDictionaryInternal
Source      : System.Management.Automation
HResult     : -2146233087
StackTrace  :
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) in /home/dkaszews/code/PowerShell/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs:line 411
   at System.Management.Automation.Runspaces.Pipeline.Invoke() in /home/dkaszews/code/PowerShell/src/System.Management.Automation/engine/hostifaces/Pipeline.cs:line 528
   at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options) in
/home/dkaszews/code/PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs:line 403

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0-preview.3
PSEdition                      Core
GitCommitId                    7.3.0-preview.3-311-g7f6b78257ebecc44ca2c3847b1241e91a61d0c97
OS                             Linux 5.15.0-1013-raspi #15-Ubuntu SMP PREEMPT Mon Aug 8 06:33:06 UTC 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup