Repository navigation
PSReadLine doesn't get loaded on some systems (and behaves unexpectedly if loaded manually) #1834
Description
Activity
- addedIssue-BugA bug to squash.A bug to squash.and removed
on Apr 2, 2019 Is this why backticks aren't working in the terminal? (I'm having the issue documented on #1299)
Get-Module PSReadLinereturns null for me.That is why backticks aren't working in v1.12.0 of the extension. This specific issue was filed against the PowerShell Preview (v2.0.1) which can load PSReadLine with a number of caveats (setting FeatureFlags and grabbing PSReadLine 2.0.0 beta4).
What's that point about FeatureFlags? Did I miss something that needs to be done to enable PSReadLine with the PowerShell [extension] Preview? If that's the case, my apologies, because this will render this issue moot...
Note: Even with Windows PowerShell 5.1, I sometimes get "PSReadline not loaded. Console will run without PSReadline." (or whatever the exact message is).
Yup, our intent was to not require the PSReadLine feature flag for the 2.0.1 preview release. But there's a bug that prevents PSRL from loading in that preview unless you specify the feature flag e.g.:
"powershell.developer.featureFlags": [ "PSReadLine" ],Tada! With that line added, I get the expected behavior.
PowerShell Integrated Console 2019-04-05 17:49:36.671: '\\sba1606\private_sba$\profile.ps1' starting... […] 2019-04-05 17:49:37.300: '\\sba1606\private_sba$\PowerShell\CheckPSReadLineStatus.ps1' starting... PSReadline version 2.0.0 beta4 is loaded 2019-04-05 17:49:37.321: '\\sba1606\private_sba$\PowerShell\CheckPSReadLineStatus.ps1' exiting. 2019-04-05 17:49:37.404: line 549: 0.733s elapsed (+0.312s) 2019-04-05 17:49:36.671: '\\sba1606\private_sba$\profile.ps1' exiting. 2019-04-05 17:49:37.462: 'C:\Users\steph\OneDrive\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1' starting... 2019-04-05 17:49:37.625: '\\sba1606\private_sba$\PowerShell\CheckPSReadLineStatus.ps1' starting... PSReadline version 2.0.0 beta4 is loaded 2019-04-05 17:49:37.696: '\\sba1606\private_sba$\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)I will test on the other affected systems at home.
For some reason I must've added the FeatureFlag setting on some but not all of my systems -- because this was a documented requirement for version 2.0.0 of the preview?
Shall we close this issue and optionally link it to the bug you were referring to?
P.S. Sorry for the "noise" ;-)
this was a documented requirement for version 2.0.0 of the preview?
Indeed it was.
Yeah, I'll go ahead and close this one. We have the link to that other defect in one of the messages above.
Thanks Keith Hill (@rkeithhill). Stéphane BARIZIEN (@sba923) PSRL will be on by default for Windows starting with the next release of the preview.
And of course it'll come with PSRL beta4 or newer 😎
That is why backticks aren't working in v1.12.0 of the extension. This specific issue was filed against the PowerShell Preview (v2.0.1) which can load PSReadLine with a number of caveats (setting FeatureFlags and grabbing PSReadLine 2.0.0 beta4).
Keith Hill (@rkeithhill) Where might we find
PSReadLine 2.0.0 beta4? I'm currently usingms-vscode.powershell-preview-2.0.1but(Get-Module PSReadLine).ModuleBasereportsPSReadLineis loading from my profile directory.Is
PSReadLinesupposed to be load from the PowerShell Extension modules directory? The~\.vscode\extensions\ms-vscode.powershell-1.12.0\modulesdirectory is being appended to my$env:PSModulePath. It seems like it should be prepended to allow extension modules to be loaded preferentially. Am I missing something?PSReadLine should be loaded from:
~\.vscode\extensions\ms-vscode.powershell-preview-2.0.1\modulesassuming you are using the PowerShell Preview extension...
If you see:
~\.vscode\extensions\ms-vscode.powershell-1.12.0\modulesthis probably means you're actually running the Stable version of the PowerShell extension and you should disable that and enable the PowerShell Preview extension.
Here's the official blog post with all of the steps:
https://devblogs.microsoft.com/powershell/announcing-the-powershell-preview-extension-in-vscode/TylerLeonhardt Um, yeah... 😞 PSReadLine does not appear to be loading from the PowerShell Extension directory but the preview is definitely installed. Is the import of PSReadLine done explicitly by the PowerShell Extension? To my eyes it seems PSReadLine is just loading from the first module it finds. If I disable the module in my profile directory PSReadLine loads from
$env:ProgramFiles\PowerShell\Modules. Am I approaching this wrong?BTW, PSReadLine vi-mode works like I would expect.
> (Get-Module PSReadLine).ModuleBase C:\Users\bubba\Documents\PowerShell\Modules\PSReadLine\2.0.0> code --list-extensions | rg powershell ms-vscode.powershell-preview> $env:PSModulePath.Split(';') C:\Users\bubba\Documents\PowerShell\Modules C:\Program Files\PowerShell\Modules c:\program files\powershell\6\Modules C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules C:\Users\bubba\.vscode-insiders\extensions\ms-vscode.powershell-preview-2.0.1\modules> Get-Module -List PSReadLine | select Name, Version, ModuleBase Name Version ModuleBase ---- ------- ---------- PSReadLine 2.0.0 C:\Users\bubba\Documents\PowerShell\Modules\PSReadLine\2.0.0 PSReadLine 2.0.0 C:\Program Files\PowerShell\Modules\PSReadLine\2.0.0 PSReadLine 2.0.0 C:\program files\powershell\6\Modules\PSReadLine PSReadLine 2.0.0 C:\Users\bubba\.vscode-insiders\extensions\ms-vscode.powershell-preview-2.0.1\modules\PSReadLine\2.0.0SydneyhSmith commented
on Apr 9, 2019 CollaboratorMore actionsGreg Wojan (@gwojan) what version of PowerShell are you using? Just to confirm, you have the feature flag on, correct?
Also, what's the output of:
gmo -list PSReadLine | % { $_.PrivateData.PSData.Prerelease }
We do our best to load the latest PSReadLine we find, but there's no ordering of prerelease tags. You may want to delete some of your PSReadLine installations there.
I did have to scan my systems for older versions of PSRL.
I wrote the attached two scripts to help me out with that:
CheckPSReadLineOnPSModulePath.ps1to scan the directories on$env:PSModulePathfor PSRL versionsCheckPSReadLineStatus.ps1to be called from profile scripts and check if PSRL is loaded and what version is loaded.
HTH
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 Flavien MICHALECZEK (@fMichaleczek) would be in place.
To do this, I have instrumented my
Microsoft.VSCode_profile.ps1with code that checks the output ofGet-Module PSReadLineso as to check which version of PSReadLine is be used.On some machines, I noticed that
Get-Module PSReadLinereturns$null.I have modified the instrumentation so that it would load PSReadLine using
Import-Module PSReadLinewhen 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:
CheckPSReadLineStatus.ps1script that checks whether PSReadLine is loaded and loads it if notMicrosoft.VSCode_profile.ps1On a system where everything works fine the integrated console displays:
On a system where the problem occurs the output is:
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 PSReadLinefromMicrosoft.VSCode_profile.ps1it 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
PSES_logs_SBAHOME_1554181156-ad5e7b0b-733a-48f5-8290-4b9400aa3d881554180886264_20190402.zip
Microsoft.VSCode_profile.ps1.zip
CheckPSReadLineStatus.zip