JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
16.7k stars 2.34k forks source link

Unable to update or install oh-my-posh from winget or gallery #1906

Closed sonicbhoc closed 2 years ago

sonicbhoc commented 2 years ago

Code of Conduct

What happened?

Here is the issue I'm having:

ResourceUnavailable: Program 'oh-my-posh.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At
C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1:188 char:6 +     (& $poshCommand
--init --shell=pwsh --config="$config") | Invoke- … +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.

And the error output:

Exception             :
    Type           : System.Management.Automation.ApplicationFailedException
    ErrorRecord    :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Program 'oh-my-posh.exe' failed to run: StandardOutputEncoding is only supported when standard
output is redirected.At C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1:188 char:6
                      +     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke- …
                      +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
            HResult : -2146233087
        CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : NativeCommandFailed
        InvocationInfo        :
            ScriptLineNumber : 188
            OffsetInLine     : 5
            HistoryId        : -1
            ScriptName       : C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1
            Line             :     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression

            PositionMessage  : At
C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1:188 char:5
                               +     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke- …
                               +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            PSScriptRoot     : C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0
            PSCommandPath    : C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1
            CommandOrigin    : Internal
        ScriptStackTrace      : at Set-PoshPrompt,
C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1: line 188
                                at <ScriptBlock>, <No file>: line 1
    TargetSite     :
        Name          : InitNativeProcess
        DeclaringType : System.Management.Automation.NativeCommandProcessor, System.Management.Automation,
Version=7.2.1.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message        : Program 'oh-my-posh.exe' failed to run: StandardOutputEncoding is only supported when standard
output is redirected.At C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1:188 char:6
                     +     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke- …
                     +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
    Data           : System.Collections.ListDictionaryInternal
    InnerException :
        Type       : System.InvalidOperationException
        TargetSite :
            Name          : Start
            DeclaringType : System.Diagnostics.Process
            MemberType    : Method
            Module        : System.Diagnostics.Process.dll
        Message    : StandardOutputEncoding is only supported when standard output is redirected.
        Source     : System.Diagnostics.Process
        HResult    : -2146233079
        StackTrace :
   at System.Diagnostics.Process.Start()
   at System.Management.Automation.NativeCommandProcessor.InitNativeProcess()
    Source         : System.Management.Automation
    HResult        : -2146233087
    StackTrace     :
   at System.Management.Automation.NativeCommandProcessor.InitNativeProcess()
   at System.Management.Automation.NativeCommandProcessor.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)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
FullyQualifiedErrorId : NativeCommandFailed
InvocationInfo        :
    ScriptLineNumber : 188
    OffsetInLine     : 5
    HistoryId        : -1
    ScriptName       : C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1
    Line             :     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression

    PositionMessage  : At C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1:188 char:5
                       +     (& $poshCommand --init --shell=pwsh --config="$config") | Invoke- …
                       +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0
    PSCommandPath    : C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1
    CommandOrigin    : Internal
ScriptStackTrace      : at Set-PoshPrompt,
C:\Users\cchristie\Documents\PowerShell\Modules\oh-my-posh\7.36.0\oh-my-posh.psm1: line 188
                        at <ScriptBlock>, <No file>: line 1

I have tried to remove and reinstall, with the same result. And when I install from winget, the module isn't picked up by PowerShell at all. Import-Module oh-my-posh says the module is not found.

Theme

Agnoster, before everything broke.

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

No posh commands work.
JanDeDobbeleer commented 2 years ago

@sonicbhoc two things. There's no module when installing with winget as the module is only a wrapper around the executable. And as for the error, you need to set your shell to UTF8 as PowerShell doesn't necessarily do that yet on Windows. See this FAQ item.

sonicbhoc commented 2 years ago

I read the faq and did what it said. I copied and pasted it to the top of my profile. Still, no dice.

I did not read the instructions on how to set up the winget install however. Nothing I have tried at all makes the PSGallery version work, but I have gotten the executable wrapper version to work.

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.