PSReadLine: Get-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception.
Environment data
& {
"PS version: $($PSVersionTable.PSVersion)"
"PSReadline version: $((Get-Module PSReadline).Version)"
if ($IsLinux -or $IsOSX) {
"os: $(uname -a)"
} else {
"os: $((dir $env:SystemRoot\System32\cmd.exe).VersionInfo.FileVersion)"
}
"PS file version: $((dir $pshome\pwsh.exe).VersionInfo.FileVersion)"
}
PS version: 6.0.0-rc.2
PSReadline version: 2.0.0
os: 6.1.7601.17514 (win7sp1_rtm.101119-1850)
PS file version: 6.0.0
$PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-rc.2
PSEdition Core
GitCommitId v6.0.0-rc.2
OS Microsoft Windows 6.1.7601 S
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.10032.0, 6.0.0-rc.2}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Steps to reproduce or exception report
Get-PSReadLineOption
Get-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception.
At line:1 char:1
+ Get-PSReadLineOption
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-PSReadLineOption], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.GetPSReadLineOption
Get-PSReadLineKeyHandler
Get-PSReadLineKeyHandler : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception.
At line:1 char:1
+ Get-PSReadLineKeyHandler
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-PSReadLineKeyHandler], TypeInitializationException
+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.GetKeyHandlerCommand
note : the issue template dont reference ‘pwsh.exe’
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29 (11 by maintainers)
Commits related to this issue
- Fix initialization for non-US keyboards (#768) Closes #614. — committed to PowerShell/PSReadLine by lzybkr 6 years ago
@eliohann you would need a new build of PSReadLine. There isn’t a new beta coming soon, but you can pick up the nightly build which has the fix: https://ci.appveyor.com/project/lzybkr/PSReadLine/branch/master/artifacts
@eliohann I installed the nightly build by replacing files in
C:\Program Files\WindowsPowerShell\Modules\PSReadline\2.0.0
And now it works with my custom keyboard layout !The problem seems to be that for some Windows keyboard layouts, the key modifiers are not considered distinct so that when the code here tries to add a new key into the dictionary, it already exists which throws an exception. My proposal for now is to not add keys that already exist. This doesn’t fix the fundamental issue that some key bindings won’t work for some keyboard layouts, but they wouldn’t work currently anyways. The temporary fix will resolve the unhandled exception so that errors aren’t being generated and
Get-PSReadLineOption
works for different keyboard layouts beyond En-US.The keyboard layout seems to be the issue, indeed. When using NEO 2.0 (special German layout) I experience the problem but switching to the ordinary built-in German layout fixes it (until switching back). Thanks for having a look at this!
I have the same error with a new install of Windows 10 Fr (1809).
Installing the specified build no longer causes the exception, but some key combinations no longer work, for example ctrl-space.
Confirming that with this fix applied everything works with slovak keyboard layout
Have an idea what the issue is, working on a fix.
@lzybkr,
Thx for your tips, when I’m on french layout, I have the issue. I switch the keyboard layout to english, no more issue.
I’ve the same issue after a upgrade of Windows 10 (insider preview). I’m not aware that I’ve installed PSReadLine so I think that it comes bundled with Win 10 (in fact, I cannot remove it via Remove/Uninstall-Module)
PSReadLine version: 2.0.0