PSReadLine 2.2.0 throws exception after upgrading to powershell 7.2.0
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues, especially the pinned issues.
Exception report
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.md
Thank you!
### Environment
PSReadLine: 2.2.0-beta2
PowerShell: 7.2.0
OS: Microsoft Windows 10.0.19043
BufferWidth: 120
BufferHeight: 30
Last 0 Keys
Exception
System.TypeLoadException: Could not load type 'System.Management.Automation.Subsystem.PredictionResult' from assembly 'Microsoft.PowerShell.PSReadLine.Polyfiller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Microsoft.PowerShell.PSConsoleReadLine.PredictionViewBase.Reset()
at Microsoft.PowerShell.PSConsoleReadLine.PredictionInlineView.Reset()
at Microsoft.PowerShell.PSConsoleReadLine.Prediction.Reset()
at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)
### Screenshot

### Environment data
```console
PS Version: 7.2.0
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.2.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.320 (WinBuild.160101.0800)
BufferWidth: 171
BufferHeight: 40
Steps to reproduce
I upgraded to PS 7.2.0 Now I see this error immediately that I start PowerShell, even if startup/profile is disabled. It may be relevant that I also have the latest VIsual Studio 2022 preview installed.
I can' t even get a prompt displayed (the exception is thrown every time I press return) although console input is being processed - if I enter 'ls' I can see a directly listing.
Expected behavior
No exception obviously
Actual behavior
What it says
I opened #2988 but will close it as it is identical to this one.
I installed Visual Studio 2022 GA yesterday, before installing PS 7.2.0 today. I did not have any of the previews installed.
I thought I'd try to revert to 2.1.0 but nothing I do seems to remove 2.2.0-beta2
PowerShell 7.2.0
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS C:\Users\neilm>
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.md
Thank you!
### Environment
PSReadLine: 2.2.0-beta2
PowerShell: 7.2.0
OS: Microsoft Windows 10.0.19043
BufferWidth: 120
BufferHeight: 30
Last 0 Keys
### Exception
System.TypeLoadException: Could not load type 'System.Management.Automation.Subsystem.PredictionResult' from assembly 'Microsoft.PowerShell.PSReadLine.Polyfiller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at Microsoft.PowerShell.PSConsoleReadLine.PredictionViewBase.Reset() at Microsoft.PowerShell.PSConsoleReadLine.PredictionInlineView.Reset() at Microsoft.PowerShell.PSConsoleReadLine.Prediction.Reset() at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics) at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)
remove-module -name psreadline
PS C:\Users\neilm> Install-Module -Name PSReadLine -RequiredVersion 2.1.0 -force
WARNING: The version '2.1.0' of module 'PSReadLine' is currently in use. Retry the operation after closing the applications.
PS C:\Users\neilm>
PS C:\Users\neilm>
I get the "in use" error even when no other Terminal tabs are open and VS Code is closed. If I then open up another Terminal tab, I just get the error about 2.2.0-beta2 again.
I am running into the same problem reported on the linked issue https://github.com/PowerShell/PSReadLine/issues/2989. I saw the old issue https://github.com/PowerShell/PSReadLine/issues/2018 but I am not seeing the same folder structure. I tried to delete this folder and reinstall PS but didn't help. I appreciate if there is a quick workaround for this issue.
Directory of C:\Program Files\PowerShell\7\Modules\PSReadLine
11/09/2021 01:00 PM <DIR> .
11/09/2021 01:00 PM <DIR> ..
11/02/2020 09:51 PM 26,308 Changes.txt
11/02/2020 09:51 PM 1,324 License.txt
11/02/2020 09:54 PM 281,992 Microsoft.PowerShell.PSReadLine2.dll
11/02/2020 09:56 PM 12,123 PSReadLine.cat
11/02/2020 09:54 PM 23,848 PSReadLine.format.ps1xml
11/02/2020 09:54 PM 13,770 PSReadLine.psd1
11/02/2020 09:54 PM 13,148 PSReadLine.psm1
11/02/2020 09:54 PM 36,248 SamplePSReadLineProfile.ps1
8 File(s) 408,761 bytes
2 Dir(s) 488,854,155,264 bytes free
I'm also facing the same issue. My output looks like this:
Environment
PSReadLine: 2.2.0-beta2 PowerShell: 7.2.0 OS: Microsoft Windows 10.0.19043 BufferWidth: 120 BufferHeight: 30
Last 0 Keys
Exception
System.TypeLoadException: Could not load type 'System.Management.Automation.Subsystem.PredictionResult' from assembly 'Microsoft.PowerShell.PSReadLine.Polyfiller, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Microsoft.PowerShell.PSConsoleReadLine.PredictionViewBase.Reset()
at Microsoft.PowerShell.PSConsoleReadLine.PredictionInlineView.Reset()
at Microsoft.PowerShell.PSConsoleReadLine.Prediction.Reset()
at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)
And I ALSO have the VS preview installed. And I updated it from a prompt inside VS Code. Which is running in a slightly older version: Version: 1.60.2 (system setup) Commit: 7f6ab5485bbc008386c4386d08766667e155244e Date: 2021-09-22T12:00:31.514Z (1 mo ago) Electron: 13.1.8 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Windows_NT x64 10.0.19043
This issue was fixed in 2.2.0-beta3 version of PSReadLine. You can fix this by upgrading to the latest 2.2.0-beta4 version of PSReadLine. Instructions for doing so:
- stop all instances of
pwsh. - from
cmd.exerun:pwsh -noprofile -command "Install-Module PSReadLine -AllowPrerelease -Force"
If you want to remove that beta version of PSReadLine and use the 2.1.0 version of PSReadLine that's shipped with PowerShell 7.2, you can:
- run
pwsh -noprofile -noninteractiveto startpwshwithout loading PSReadLine - run
Uninstall-Module -Name PSReadLine -RequiredVersion <2.2.0-beta1 or 2.2.0-beta2> -AllowPrereleaseto remove the module. Or, you can manually remove that module folder.
I tried
Uninstall-Module -Name PSReadLine -RequiredVersion 2.2.0-beta1 -AllowPrerelease
as @daxian-dbw suggested and that fixed the problem.
To install latest Beta release, open Admin CMD:
cd C:\Program Files\PowerShell\7
pwsh.exe -noprofile -command "Install-Module PSReadLine -Force -AllowPrerelease -SkipPublisherCheck"
(Note: Apparently no need to uninstall the older version.)