Skip to content

Command 'PowerShell: Show Extension Terminal' resulted in an error (command 'PowerShell.ShowSessionConsole' not found) #4136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
bender-the-greatest opened this issue Aug 16, 2022 · 21 comments · Fixed by #4140
Assignees
Labels

Comments

@bender-the-greatest
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

The current version of the PowerShell plugin does not load when I open .ps1 files any longer. When I try to launch the integrated terminal with PowerShell: Show Extension Terminal from the command pallete, I get the following error (re-stated from title):

Command 'PowerShell: Show Extension Terminal' resulted in an error (command 'PowerShell.ShowSessionConsole' not found)

Rolling back to the prior version fixes this (albeit with the old PowerShell Integrated Console name for the terminal). I've found at least one other person today experiencing the same issue. I've also tried the related PowerShell: Restart Current Session command which results in a similar "command not found" error.

Recently-created issue #4135 seems like it could be related although it's for a specific plugin feature. My issue here is that the terminal not launching causes the plugin to entirely not function.

PowerShell Version

> $psversiontable

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

> code --version
1.70.1
6d9b74a70ca9c7733b29f0456fd8195364076dda
x64

Extension Version

> code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2022.7.2

Steps to Reproduce

  1. Open .ps1 file for editing.

  2. No plugin features are available. Quick evidence of this is no syntax checking is performed against the opened file.

  3. Try to open the plugin terminal with the PowerShell: Show Extension Terminal pallete command. Modal dialog with the following error is displayed:

    Command 'PowerShell: Show Extension Terminal' resulted in an error (command 'PowerShell.ShowSessionConsole' not found)

Visuals

No response

Logs

No logs are generated when running PowerShell: Show Extension Terminal from the command pallete. I set logging to Diagnostic before attempting this.

@bender-the-greatest bender-the-greatest added the Issue-Bug A bug to squash. label Aug 16, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Aug 16, 2022
@andyleejordan
Copy link
Member

Hello! The latest code is available in the PowerShell Preview for VS Code, and includes a myriad of fixes. Could you verify if this issue still reproduces using the preview extension? Please note that this preview is likely to include other bugs, and you should feel free to file new issues for those so we can work through them. Thanks again!

@SydneyhSmith SydneyhSmith added Needs: Repro Info 🤔 and removed Needs: Triage Maintainer attention needed! labels Aug 16, 2022
@andyleejordan
Copy link
Member

Could you also check your workspace file and ensure it's valid JSON?

@dbaileyut
Copy link

dbaileyut commented Aug 16, 2022

I'm reproducing on v2022.7.2 when I have a workspace with no folders. If I add a folder, the extension behaves as expected.

I'm not seeing it on the preview v2022.8.2.

Test workspace is just:

{
	"folders": []
}

In the VSCode developer tools console, I see:

mainThreadExtensionService.ts:111 Activating extension 'ms-vscode.powershell' failed: Cannot read properties of undefined (reading 'uri').

TypeError: Cannot read properties of undefined (reading 'uri')
	at Object.<anonymous> (c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:57:23283)
	at Generator.next (<anonymous>)
	at c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:1:945
	at new Promise (<anonymous>)
	at vt (c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:1:765)
	at Object.tD (c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:57:22820)
	at c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:116:12087
	at Generator.next (<anonymous>)
	at c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:1:945
	at new Promise (<anonymous>)
	at vt (c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:1:765)
	at TN (c:\Users\myuser\.vscode\extensions\ms-vscode.powershell-2022.7.2\out\main.js:116:11768)
	at Function._callActivateOptional (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:97:17473)
	at Function._callActivate (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:97:17131)
	at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:97:14942
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async v._activate (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:8180)
	at async v._waitForDepsThenActivate (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:8122)
	at async v._initialize (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:85:7486)

@bender-the-greatest
Copy link
Author

bender-the-greatest commented Aug 16, 2022 via email

@dbaileyut
Copy link

dbaileyut commented Aug 16, 2022

My workspace is also not completely empty as the other person mentioned in their reproduction of the issue.

Sorry, saw this on Reddit and it looked like what I experienced. My issue is actually a dupe of #4102

@andyleejordan
Copy link
Member

If it's not reproducing with v2022.8.2 then it's fixed 😆

@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Repro Info 🤔 labels Aug 16, 2022
@andyleejordan
Copy link
Member

Oh, you're not the OP.

@andyleejordan andyleejordan removed the Resolution-Fixed Will close automatically. label Aug 16, 2022
@andyleejordan andyleejordan self-assigned this Aug 16, 2022
@bender-the-greatest
Copy link
Author

I updated to the Preview extension (v2022.8.2) and I am still getting the same behavior.

@bender-the-greatest
Copy link
Author

I was able to get a little more information from the logs during VS Code startup this time (with the Preview extension still installed). Not sure why I didn't get this the last time I went through the logs, but I'm getting the following error now when the extension tries to load:

[2022-08-17 09:59:27.834] [exthost] [error] Activating extension ms-vscode.powershell-preview failed due to an error:
[2022-08-17 09:59:27.834] [exthost] [error] Error: Can not delete in empty document
    at R (vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:19:2203)
    at T.getEdits (vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2692:4143)
    at T.updateConfiguration (vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2692:3377)
    at T.doWriteConfiguration (vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2692:2981)
    at async Object.factory (vscode-file://vscode-app/c:/Program%20Files/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2692:2641)

@andyleejordan
Copy link
Member

That makes sense given what other people have seen. I just need to get a local repro. Essentially around where we read and write to the workspace (if you have multiple root folders, we ask you to select which folder for the cwd and then remember the selection), I need a catch to handle bad workspaces Code is having trouble reading/writing.

@bender-the-greatest
Copy link
Author

Would it help if I share my workspace file?

@bender-the-greatest
Copy link
Author

Okay, I just got this to work with the Preview plugin, but I'm not sure why I haven't gotten this prompt up until this point. It asked me to select a working directory for the PowerShell extension. Now it remembers and loads up every time.

I think this might be the crux of the issue, if the extension needs a working directory selected by the end user. But the current stable extension was not asking me this for some reason, and the first few times I launched the Preview version of the extension it did not prompt me either. Is there a way we can manually set the extension working directory if not prompted?

@bender-the-greatest
Copy link
Author

Additionally, after setting the plugin working directory, removing the preview extension, and installing the stable extension v2022.7.2, the stable extension indeed works fine now.

@bender-the-greatest
Copy link
Author

bender-the-greatest commented Aug 17, 2022

I found the extension setting for setting the working directory in the workspace. I tested setting this to a different location than I picked in the prompt and the PS extension continues to work fine. If you don't get the prompt to pick a working directory for the plugin, the following setting is where you can set this:

"powershell.cwd": "c:\\path\\to\\working\\directory\\"

I have this set now to my root workspace folder. To re-state, if you don't get prompted to set the extension working directory and the extension fails to load, setting the above setting in your workspace should fix this issue (don't forget to use a real path).

@andyleejordan
Copy link
Member

I think I need to get the preview extension out sooner rather than later 😆 The setting is powershell.cwd. Previously we just defaulted to the first folder of the list of folders in a multi-root workspace. In an effort to properly support multi-root workspaces I added the choice option to pick and remember which one. I think there was a bug that made it's way into stable around testing the existence of the folder, and that's fixed in preview. Keep in mind, it should only ask if you have setup a workspace file with multiple named items under the folders key (e.g. VS Code's multi-root workspace feature). Can you confirm your workspace is setup like that?

@andyleejordan
Copy link
Member

andyleejordan commented Aug 17, 2022

@bender-the-greatest I'm losing track of bugs here. Your first post in this issue was about a multi-root workspace with the edge case of zero folders. @dbaileyut's bug in this issue was about a multi-root workspace with the edge case of zero folders That has been fixed in the preview extension: #4104, and so that portion of this issue is actually a duplicate of #4102.

@andyleejordan
Copy link
Member

@bender-the-greatest what's your workspace file that repros this? Would be very helpful. I want to get a proper try/catch for this and for #4135 into the preview before rolling it to stable.

@bender-the-greatest
Copy link
Author

Can you confirm your workspace is setup like that?

I have multiple folders added to the workspace if that's what you mean. In the code-workspace JSON there are multiple directories listed under the folders array.

Your first post in this issue was about a multi-root workspace with the edge case of zero folders.

That was someone else, I have multiple folders added to my workspace.

@bender-the-greatest
Copy link
Author

bender-the-greatest commented Aug 17, 2022

I don't think the workspace file will help at this point. The issue seems to have been that powershell.cwd was not set, and I was not prompted to set this until after a few attempts of trying to get the plugin to load. Nonetheless let me revert the fix and see if I can reproduce the lack of prompt again with this, if I can I will share it.

@bender-the-greatest
Copy link
Author

bender-the-greatest commented Aug 17, 2022

Alright, while I can't reproduce the prompt not appearing at all anymore, I can replicate the erroneous extension behavior by clicking away rather than selecting a working directory when two or more folders are added to the workspace, and powershell.cwd is also not set:

repro-issue.code-workspace

{
  "folders": [
    {
      "name": "ChocolateyPackages",
      "path": "ChocolateyPackages"
    },
    {
      "path": "scratch"
    }
  ]
}

Repository owner moved this from In Progress to Done in American Pharoah Aug 18, 2022
@andyleejordan
Copy link
Member

Ok, new preview will be out momentarily. Could you please confirm you can no longer repro this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants