System Details Output
### VSCode version: 1.48.1 3dd905126b34dcd4de81fa624eb3a8cbe7485f13 x64
### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
### PSES version:
### PowerShell version:
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I am experiencing a problem with the PowerShell session menu during extension loading.
Clicking on the button _馃攧 Starting PowerShell_ (at the bottom-right) should do nothing (if the extension is not ready) or should open the PowerShell session menu.
The PowerShell session menu fails to open and the following error notification is displayed:
Running the contributed command: 'PowerShell.ShowSessionMenu' failed.
_Note:_ with _PowerShellGet_ and _PackageManagement_ up-to-date, if I wait for the extension to fully load, _馃攧 Starting PowerShell_ button is replaced by the PowerShell version (e.g. _[>] 5.1_) and the session menu can now be opened.
The following error message is logged (Extension Host):
[2020-08-22 14:53:14.183] [exthost] [error] TypeError: Cannot read property 'displayVersion' of undefined
at SessionManager.showSessionMenu (c:\Users\xxxx\.vscode\extensions\ms-vscode.powershell-2020.6.0\out\src\session.js:520:55)
at c:\Users\xxxx\.vscode\extensions\ms-vscode.powershell-2020.6.0\out\src\session.js:303:91
at _executeContributedCommand (c:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:642:374)
[...]
When I debug some values in session.js (showSessionMenu method), I get this:
availablePowerShellExes (L504): [{"exePath":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","displayName":"Windows PowerShell (x64)","knownToExist":true},{"exePath":"C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe","displayName":"Windows PowerShell (x86)","knownToExist":true}]this.PowerShellExeDetails (L514): {"exePath":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","displayName":"Windows PowerShell (x64)","knownToExist":true}currentPowerShellExe (L514): undefinedthis.versionDetails (L514): undefinedthis.versionDetails.displayVersion (L516) logically fails and throws the previous TypeError.
The following modification (L512) seems to fix the issue (and makes sense to me):
const currentPowerShellExe = availablePowerShellExes
- .find((item) => item.displayName.toLowerCase() === this.PowerShellExeDetails.displayName);
+ .find((item) => item.displayName.toLowerCase() === this.PowerShellExeDetails.displayName.toLowerCase());
With this modification, the first value of availablePowerShellExes is now assigned to currentPowerShellExe and the following ternary condition assigns currentPowerShellExe.displayName to powerShellSessionName without throwing the previous error.
This proposal may not be the right one. You may even consider that this issue is not really valid as the session menu succeeds to open when the extension is fully started. Maybe that a click on the button should not call the ShowSessionMenu command while the extension is loading?
Thanks @GaelGirodon for providing the detailed info, and debugging the issue--if you are interested we would also accept a PR with that fix, thanks!
Thanks @SydneyhSmith for your answer. It would be a pleasure to help you to fix this issue but I don't think I know enough about this project to create a PR with all the required tests in a reasonable timeframe. I'd need to take some time to dig a bit into the source code, tests and PR process. The fix (if it is the right one) is really small (add: .toLowerCase()). It would surely be easier and faster for the main contributors to integrate this slight modification 馃槈
Thanks @GaelGirodon unfortunately we do not know when we will have the capacity to fix this so I will mark it as up for grabs...if you do decide to contribute we can help with the process--thanks!
@SydneyhSmith So forked and cloned both repositories mentioned in the contrib documentation, and followed the steps, but am unable to actually build the modified extension to see if @GaelGirodon suggestion even works. I'm open to suggestions on how to proceed.
ah...nevermind it's building :) https://github.com/PowerShell/vscode-powershell/pull/2972
@SydneyhSmith @GaelGirodon https://github.com/PowerShell/vscode-powershell/pull/2973 Not sure where this should be merged into
Fixed in #2973