Closed mattcargile closed 2 years ago
@mattcargile in the first case (standard prompt failing), can you have a look of the contents of the $error
variable ? This error comes from the init script and is a PowerShell issue, not one the comes from the oh-my-posh golang binary. That one isn't even invoked here and the error you provided is pretty generic and does not display the actual issue. We fetch the following two parameters to get the actual path which are then passed as a string to oh-my-posh (so that should always work, unless the string values can't be resolved OR the output is different?):
$cleanPWD = $PWD.ProviderPath
$cleanPSWD = $PWD.ToString()
Can you check what the values are for these two in this specific case? ProviderPath could the the issue.
Thanks for the notes. After I disconnected from my VPN while my $PWD
is a UNC path, I started troubleshooting
Below is the $Error[0]
, which is what I attempted to copy before but I think when I piped it to Set-Clipboard
, it got butchered. I also checked the $PWD
property references and they returned without error.
ErrorRecord : Program 'oh-my-posh.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At line:93 char:22
+ … dardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cle …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
WasThrownFromThrowStatement : False
TargetSite : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
Message : Program 'oh-my-posh.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At line:93 char:22
+ … dardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cle …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException : System.InvalidOperationException: StandardOutputEncoding is only supported when standard output is redirected.
at System.Diagnostics.Process.Start()
at System.Management.Automation.NativeCommandProcessor.InitNativeProcess()
HelpLink :
Source : System.Management.Automation
HResult : -2146233087
StackTrace : at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)
I guess it is complaining about this line?
Side note: How does that $omp="::OMP::"
work? That is interesting.
Did a little more troubleshooting and replaced that aforementioned line 93 in the omp.ps1
with the below.
$standardOut = @(&$omp --error="$errorCode" --pwd="$HOME" --pswd="$HOME" --execution-time="$executionTime" --stack-count="$stackCount" --config="$config" --terminal-width=$terminalWidth 2>&1)
Still broken and returns a PS>
prompt. I tried to look around a little bit with sysinternals tool procmon.exe
but I didn't have much luck.
@mattcargile the more I look at the pattern it seems that PowerShell (or PSReadline) can't handle running an executable when in this use-case. The error you see has nothing to do with oh-my-posh, it's PowerShell that fails.
Yeah I see! I couldn't even run oh-my-posh.exe --version
to output. conhost.exe
pops up for a second and no output to the original terminal ( wt.exe
) occurred. Even ipconfig
exhibits similar behavior. It's like the output is being pushed to a conhost.exe
/cmd.exe
and avoiding wt.exe
altogether. I tried in powershell.exe
too.
I guess we can close this out. I tried a quick Google for the issue and didn't have much success.
I was able to reproduce the issue using conhost.exe
as my terminal instead of wt.exe
.
Thanks for helping me understand it.
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.
Code of Conduct
What happened?
Not sure if there is anything I can do about this. I was thinking there might be some resolver in source? Maybe this should be a discussion as I could potentially use the
template
property?While on VPN, my
$PWD
may be a UNC. If my connection expires, then when I use the Terminal ( i.e.wt.exe
) my prompt becomesPS>
upon next command run or<ENTER>
key press. This behavior also occurs if ISet-Location
to a location without an owner ( or owned by only the[NT AUTHORITY]\System
).I started a
pwsh.exe -NoProfile
and then I ran the below to make sure I didn't have some other$PROFILE
problem. This was prior to testing the same expressed above.Is there a way to more gracefully fail and show empty text for the
path
component?Theme
What OS are you seeing the problem on?
Windows
Which shell are you using?
powershell
Log Note
Write-PoshDebug
fails when my$PWD
is a UNC path that I can't connect to. Here is the error when I run the aforementioned function.Log output