PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.67k stars 292 forks source link

Trying to install oh my posh, in post-install running into issues. #4067

Closed khraosgenetor closed 1 month ago

khraosgenetor commented 1 month ago

Prerequisites

Exception report

PS C:\Users\alien\posh-git> Find-Module -Name PSReadLine -Repository PSGallery | Get-Member
PS C:\Users\alien\posh-git> oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression
Set-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception.
At line:456 char:5
+     Set-PSReadLineOption -ContinuationPrompt (@(Start-Utf8Process $sc ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-PSReadLineOption], TypeInitializationException
    + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.SetPSReadLineOption

PS>

Screenshot

image

Environment data

PS Version: 5.1.22621.3810
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.5
Get-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception.
At line:21 char:41
+     Write-Host "PSReadLine EditMode: $((Get-PSReadLineOption).EditMod ...
+                                         ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-PSReadLineOption], TypeInitializationException
    + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.GetPSReadLineOption

PSReadLine EditMode:
OS: 10.0.22621.1 (WinBuild.160101.0800)
BufferWidth: 208
BufferHeight: 60

Steps to reproduce

exec " oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression"

Expected behavior

No normal exeptions

Actual behavior

Runs into the error: Set-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception. At line:456 char:5

daxian-dbw commented 1 month ago

Can you share the script generated by oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json"? Also, can you share all the inner exceptions of the "type initializer" exception you got?

khraosgenetor commented 1 month ago

Can you share the script generated by oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json"? Also, can you share all the inner exceptions of the "type initializer" exception you got?

How do I get the inner exception?

Also the script: (@(& 'C:/Users/alien/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh.exe' init pwsh --config='C:\Users\alien\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json' --print) -join "`n") | Invoke-Expression

khraosgenetor commented 1 month ago

Nevermind sorry, The Powershell from Terminal did not allow me to use the above script. I manually created a new profile, which now works. Sorry for the trouble.