Skip to content

PSReadLine doesn't get loaded on some systems (and behaves unexpectedly if loaded manually) #1834

Closed
@sba923

Description

@sba923

Issue Description

While helping out with issue #1570 I had to replace all instances of PSReadLine on my systems with 2.0.0 beta4, and to make sure VScode would either run with that version of PSReadLine, or that a workaround from @fMichaleczek would be in place.

To do this, I have instrumented my Microsoft.VSCode_profile.ps1 with code that checks the output of Get-Module PSReadLine so as to check which version of PSReadLine is be used.

On some machines, I noticed that Get-Module PSReadLine returns $null.

I have modified the instrumentation so that it would load PSReadLine using Import-Module PSReadLine when PSReadLine is found not to be loaded. When this is done, PSReadLine does get loaded and enabled, but doesn't function as expected: saved-on-disk history is not restored, syntax highlighing is not performed.

Attached are:

  • the CheckPSReadLineStatus.ps1 script that checks whether PSReadLine is loaded and loads it if not
  • the complete Microsoft.VSCode_profile.ps1

On a system where everything works fine the integrated console displays:

PowerShell Integrated Console
[...]
2019-04-02 06:53:49.503: 's:\PowerShell\CheckPSReadLineStatus.ps1' starting...
PSReadline version 2.0.0 beta4 is loaded
2019-04-02 06:53:49.518: 's:\PowerShell\CheckPSReadLineStatus.ps1' exiting.
2019-04-02 06:53:49.520: line 549: 2.749s elapsed (+1.538s)
2019-04-02 06:53:46.771: 'S:\profile.ps1' exiting.
2019-04-02 06:53:49.546: 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1' starting...
2019-04-02 06:53:49.575: 's:\PowerShell\CheckPSReadLineStatus.ps1' starting...
PSReadline version 2.0.0 beta4 is loaded
2019-04-02 06:53:49.582: 's:\PowerShell\CheckPSReadLineStatus.ps1' exiting.
PSReadline version 2.0.0 beta4 is loaded
No 'endless loop' workaround should be needed (PSReadLine is version 2.0.0 beta4)

On a system where the problem occurs the output is:

PowerShell Integrated Console
2019-04-01 21:33:16.814: 'S:\profile.ps1' starting...
[...]
2019-04-01 21:33:18.997: 's:\PowerShell\CheckPSReadLineStatus.ps1' starting...
PSReadLine is not loaded!!!???
2019-04-01 21:33:19.000: 's:\PowerShell\CheckPSReadLineStatus.ps1' exiting.
2019-04-01 21:33:19.001: line 549: 2.187s elapsed (+0.841s)
2019-04-01 21:33:16.814: 'S:\profile.ps1' exiting.
2019-04-01 21:33:19.022: 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1' starting...
2019-04-01 21:33:19.042: 's:\PowerShell\CheckPSReadLineStatus.ps1' starting...
PSReadLine is not loaded!!!???
PSModulePath is: 
C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Users\steph\.vscode\extensions\ms-vscode.powershell-preview-2.0.1\modules
Attempting to Import-Module PSReadLine
VERBOSE: Loading module from path 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Modules\PSReadLine\2.0.0\PSReadLine.psd1'.
VERBOSE: Cannot verify the Microsoft .NET Framework version 4.6.1 because it is not included in the list of permitted versions.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Modules\PSReadLine\2.0.0\PSReadLine.format.ps1xml'.
VERBOSE: Loading module from path 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Modules\PSReadLine\2.0.0\Microsoft.PowerShell.PSReadLine2.dll'.
VERBOSE: Importing cmdlet 'Get-PSReadLineOption'.
VERBOSE: Importing cmdlet 'Set-PSReadLineOption'.
VERBOSE: Importing cmdlet 'Set-PSReadLineKeyHandler'.
VERBOSE: Importing cmdlet 'Get-PSReadLineKeyHandler'.
VERBOSE: Importing cmdlet 'Remove-PSReadLineKeyHandler'.
VERBOSE: Loading module from path 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Modules\PSReadLine\2.0.0\PSReadLine.psm1'.
VERBOSE: Exporting function 'PSConsoleHostReadLine'.
VERBOSE: Exporting cmdlet 'Get-PSReadLineOption'.
VERBOSE: Exporting cmdlet 'Set-PSReadLineOption'.
VERBOSE: Exporting cmdlet 'Set-PSReadLineKeyHandler'.
VERBOSE: Exporting cmdlet 'Get-PSReadLineKeyHandler'.
VERBOSE: Exporting cmdlet 'Remove-PSReadLineKeyHandler'.
VERBOSE: Importing cmdlet 'Get-PSReadLineKeyHandler'.
VERBOSE: Importing cmdlet 'Get-PSReadLineOption'.
VERBOSE: Importing cmdlet 'Remove-PSReadLineKeyHandler'.
VERBOSE: Importing cmdlet 'Set-PSReadLineKeyHandler'.
VERBOSE: Importing cmdlet 'Set-PSReadLineOption'.
VERBOSE: Importing function 'PSConsoleHostReadLine'.
2019-04-01 21:33:19.387: 's:\PowerShell\CheckPSReadLineStatus.ps1' invoking itself after Import-Module...
2019-04-01 21:33:19.399: 'S:\PowerShell\CheckPSReadLineStatus.ps1' starting...
PSReadline version 2.0.0 beta4 is loaded
2019-04-01 21:33:19.411: 'S:\PowerShell\CheckPSReadLineStatus.ps1' exiting.
PSReadline version 2.0.0 beta4 is loaded
No 'endless loop' workaround should be needed (PSReadLine is version 2.0.0 beta4)

Expected Behaviour

PSReadLine should always be loaded in the PowerShell Integrated Console

Actual Behaviour

On some systems PSReadLine doesn't get loaded, and when loaded by invoking Import-Module PSReadLine from Microsoft.VSCode_profile.ps1 it doesn't behave properly: saved-on-disk history is not restored, syntax highlighing is not done.

Attached Logs

(PSES logs from a system where the problem occurs)

System Details

System Details Output from a system where the problem occurs

### VSCode version: 1.32.3 a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4 x64

### VSCode extensions:
alefragnani.Bookmarks@10.4.1
anseki.vscode-color@0.4.5
austin.code-gnu-global@0.2.2
DougFinke.vscode-PSStackoverflow@0.0.2
Gruntfuggly.todo-tree@0.0.126
mechatroner.rainbow-csv@1.0.0
ms-vscode.cpptools@0.22.1
ms-vscode.powershell@1.12.0
ms-vscode.powershell-preview@2.0.1
msjsdiag.debugger-for-chrome@4.11.3
nobuhito.printcode@3.0.0
tht13.html-preview-vscode@0.2.5
VisualStudioExptTeam.vscodeintellicode@1.1.5
yzhang.markdown-all-in-one@2.2.0
zovorap.ab-html-formatter@0.0.2


### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.17763.316
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.316
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PSES_logs_SBAHOME_1554181156-ad5e7b0b-733a-48f5-8290-4b9400aa3d881554180886264_20190402.zip
Microsoft.VSCode_profile.ps1.zip
CheckPSReadLineStatus.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions