Skip to content

PowerShell Integrated Console (PSIC) is not created on VSCode startup #2900

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
pcgeek86 opened this issue Aug 20, 2020 · 13 comments
Closed

PowerShell Integrated Console (PSIC) is not created on VSCode startup #2900

pcgeek86 opened this issue Aug 20, 2020 · 13 comments

Comments

@pcgeek86
Copy link
Contributor

pcgeek86 commented Aug 20, 2020

System Details Output

### VSCode version: 1.48.0 db40434f562994116e5b21c24015a2e40b2504e6 x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 

### PowerShell version:

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


Issue Description

I was trying to debug the root cause for Intellisense not working in the VSCode-PowerShell extension, when I came across the following error message in the vscode-powershell.log file, in my diagnostic logs folder.

image

PSIC is not active terminal. Running in active terminal using 'runSelectedText'

I had to create a dummy script, use F5 to run that, and then the PSIC got created. Suddenly, Intellisense for third-party modules / objects started working again.

Question: Is there some way to ensure that PSIC is always spun up when VSCode is re-launched, when a PowerShell script file is opened up? I wonder if this is partly why people are having so many problems with broken Intellisense.

Expected Behaviour

Intellisense works at startup

Actual Behaviour

Intellisense for third-party entities (modules, .NET libraries, etc.) doesn't work on VSCode startup.

Known Work-around

  1. Create a dummy PowerShell script
  2. Use F5 to invoke the dummy script
  3. Intellisense starts working in PSIC

Related Issues

#2745

There are only two mentions of the exact log message that I pasted above, but neither one seems to address the PSIC not being created at startup time.

image

@ghost ghost added the Needs: Triage Maintainer attention needed! label Aug 20, 2020
@TylerLeonhardt
Copy link
Member

@pcgeek86 can you please share your vscode settings here?

@rjmholt
Copy link
Contributor

rjmholt commented Aug 20, 2020

I believe this is a question of VSCode activating the PowerShell extension, which is configured by the extension's declared activation events.

I think these are static for the extension, and not configurable on a user basis. Meaning any configuration for this that the extension ships would apply to all users.

Here are the currently configured activation events:

"activationEvents": [
"onDebugInitialConfigurations",
"onDebugResolve:PowerShell",
"onLanguage:powershell",
"onCommand:PowerShell.NewProjectFromTemplate",
"onCommand:PowerShell.OpenExamplesFolder",
"onCommand:PowerShell.PickPSHostProcess",
"onCommand:PowerShell.PickRunspace",
"onCommand:PowerShell.SpecifyScriptArgs",
"onCommand:PowerShell.ShowSessionConsole",
"onCommand:PowerShell.ShowSessionMenu",
"onCommand:PowerShell.RestartSession",
"onCommand:PowerShell.EnableISEMode",
"onCommand:PowerShell.DisableISEMode",
"onCommand:PowerShell.RegisterExternalExtension",
"onCommand:PowerShell.UnregisterExternalExtension",
"onCommand:PowerShell.GetPowerShellVersionDetails",
"onView:PowerShellCommands",
"onNotebookEditor:PowerShellNotebookMode"
],

That's:

  • When a PowerShell file is opened
  • When a debug configuration is found
  • When any exported commands are used
  • When the PowerShell Command Explorer is opened

The remaining events that might help here are:

  • onUri: seems to be for when custom extension URIs are opened, but could be a hook for us to use here?
  • workspaceContains: it would be possible to create a simple file to function as a workspace to trigger extension startup
  • onStartupFinished: this would achieve the desired outcome, but would start the extension for all users, and is an experience I don't think we want to force on people

The ideal solution I think would be a VSCode setting to start listed extensions at startup. We would need to ask for that in the VSCode repo.

@rjmholt rjmholt added Area-Startup Issue-Enhancement A feature request (enhancement). and removed Area-IntelliSense Needs: Triage Maintainer attention needed! labels Aug 20, 2020
@pcgeek86
Copy link
Contributor Author

Here's my VSCode settings.

{
    "telemetry.enableTelemetry": false,
    "window.zoomLevel": 0,
    "editor.fontFamily": "'UbuntuMono Nerd Font', Consolas, 'Courier New', monospace",
    "powershell.powerShellAdditionalExePaths": [
        {
            "exePath": "C:\\Users\\TrevorSullivan\\scoop\\apps\\pwsh\\current\\pwsh.exe",
            "versionName": "PowerShellCore"
        }
    ],
    "powershell.powerShellDefaultVersion": "PowerShellCore",
    "terminal.integrated.shell.windows": "C:\\Users\\TrevorSullivan\\scoop\\apps\\pwsh\\current\\pwsh.exe",
    "powershell.integratedConsole.focusConsoleOnExecute": false,
    "powershell.integratedConsole.suppressStartupBanner": true,
    "powershell.integratedConsole.showOnStartup": false,
    "debug.openDebug": "neverOpen",
    "explorer.confirmDelete": false,
    "git.autofetch": true,
    "aws.telemetry": false,
    "explorer.confirmDragAndDrop": false,
    "workbench.colorTheme": "Nord",
    "workbench.startupEditor": "newUntitledFile",
    // "powershell.developer.editorServicesLogLevel": "Diagnostic"
}

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 20, 2020
@pcgeek86
Copy link
Contributor Author

@rjmholt But when I do a Reload Window operation, I already have a PowerShell file opened up. The extension isn't being activated despite that. This is a bug, not an enhancement.

@pcgeek86
Copy link
Contributor Author

pcgeek86 commented Aug 20, 2020

In case it matters, the PowerShell file that I have opened up is being saved using the VSCode persistence mechanism. I don't know the details of how that feature is implemented.

The script file has not been saved to disk. Perhaps that is why PSIC isn't being activated?

EDIT: Saved file to disk, reloaded VSCode window, and PSIC still isn't starting up, even though .ps1 file is still getting opened up. I uploaded a video to share with you, that shows the repro. See e-mail shortly.

@TylerLeonhardt
Copy link
Member

@pcgeek86 do you have any workspace-level settings?

@rjmholt
Copy link
Contributor

rjmholt commented Aug 20, 2020

@pcgeek86 your video doesn't show the crucial part where VSCode and the first script file are opened. Nothing works from that point because there's no PowerShell session (hence no PSIC). But the question is why is there no PSIC initially. We need further information about that point where the first file is opened to find out why the PowerShell extension isn't being triggered.

@rjmholt rjmholt added Needs-Repro-Info and removed Issue-Enhancement A feature request (enhancement). labels Aug 20, 2020
@pcgeek86
Copy link
Contributor Author

@TylerLeonhardt No workspace-level settings.

@rjmholt The video shows me doing a "reload window" at 1:00.

@pcgeek86
Copy link
Contributor Author

Here's another repro from scratch. You can see me close all workspaces / files, and then reopen VSCode again. There is no PSIC each time that I start up VSCode.

  • The PowerShell extension is activated
  • There is no PSIC, until I manually execute the workaround in the OP

pwsh

@TylerLeonhardt
Copy link
Member

@pcgeek86 get rid of this setting:

"powershell.integratedConsole.showOnStartup": false,

does that change anything?

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Maintainer Attention Maintainer attention needed! labels Aug 20, 2020
@pcgeek86
Copy link
Contributor Author

@TylerLeonhardt Yes, that solves it. I can't remember why I added that in there, a long while back. Probably because there are duplicate PowerShell terminals, that makes VSCode a little more confusing. Is there some way for the extension to piggy back on the pwsh instance, instead of spinning up a second one (PSIC)?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 20, 2020
@TylerLeonhardt
Copy link
Member

It's not possible. That terminal is created by VS Code and not the extension.

We've thought about killing that terminal at start up, but if the user has important info there (like they ran a command), then we would cause them harm.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Aug 21, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Aug 21, 2020

It seems like a bug that completions don't occur if the PSIC isn't visible though. I wonder what causes that.

Is there some way for the extension to piggy back on the pwsh instance, instead of spinning up a second one (PSIC)?

To do that, the extension client would need to find that PowerShell process and inject the server into it. In general with other processes, that's not possible, but PowerShell does listen for Enter-PSHostProcess connections. Naturally to connect to one of those you need an Enter-PSHostProcess client, which means a PowerShell process, so you're back to where you started. Moreover, it would just take your initial pwsh instance and turn it into the PSIC; any reason you might have to use pwsh over the PSIC would evaporate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants