Skip to content

Cannot activate extension #4169

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
4 of 6 tasks
memory-yiyi opened this issue Sep 9, 2022 · 28 comments
Closed
4 of 6 tasks

Cannot activate extension #4169

memory-yiyi opened this issue Sep 9, 2022 · 28 comments
Labels
Issue-Bug A bug to squash. Resolution-Answered Will close automatically.

Comments

@memory-yiyi
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

PowerShell extension is always in "activating state", shell integration cannot be activated.
image

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.22622
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

1.71.0
784b0177c56c607789f9638da7b6bf3230d47a8c
x64

Extension Version

Steps to Reproduce

  1. Open a PS1 file
  2. Waiting for extension activation
  3. After a long time, it is still activated

Visuals

image

Logs

No response

@memory-yiyi memory-yiyi added the Issue-Bug A bug to squash. label Sep 9, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Sep 9, 2022
@memory-yiyi
Copy link
Author

memory-yiyi commented Sep 12, 2022

Some error log.
image

@andyleejordan
Copy link
Member

Hi,

Could you please provide more logging and environment information by following these steps?

Thanks!

Regarding shell integration, that is not yet supported in the extension, but it's on our upcoming list.

@memory-yiyi
Copy link
Author

I'm sorry to tell you that the extension can't be activated, so you can't get logs through the extension, but you can get these.
image

@memory-yiyi
Copy link
Author

It is worth noting that the same version of Linux can be activated, although I am not sure whether it is just because of system differences.
image

@andyleejordan
Copy link
Member

The screenshot you've provided indicates that enough of the extension has started that you should be able to get much of those logs we're looking for, specifically the ones from PowerShell Editor Services.

@memory-yiyi
Copy link
Author

Came out this time, hope it's useful.
EditorServices.log

@memory-yiyi
Copy link
Author

It is always in the process of activation. It was not like this a few weeks ago. It happened suddenly.
I tried to roll back the extended version, but it didn't solve the problem.

@memory-yiyi
Copy link
Author

This is another bug of win11. The last time vs2022 had a similar fault. The problem has been solved by updating to 22622.598. Thank you for your answer.

@memory-yiyi
Copy link
Author

I'm sorry to say that it only works once after the update. When I turn off the computer and turn it on again, it returns to the problem mentioned earlier.

@memory-yiyi
Copy link
Author

I found a rule. At present, the normal startup of the extension must meet this condition:

  • After turning on the computer, the first application to be opened must be a vscode extension to start normally.

In other words, the common operations listed below will cause the extension exception:

  1. After starting up, open other desktop applications, and then start vscode.
  2. Restart vscode.

The situation is somewhat complicated. I am not sure whether it is an extension problem, a vscode problem or an operating system problem.

@memory-yiyi
Copy link
Author

memory-yiyi commented Sep 13, 2022

Locked problem cause:

  • In the process of continuous troubleshooting, it was unexpectedly found that extension in safe mode works normally under any condition. Go to the normal environment. When there is no networking, the expansion works normally under any conditions.

Based on this, please check what problems the Internet has brought. I don't have relevant knowledge and can do nothing about it, so please.

@andyleejordan
Copy link
Member

Hey @memory-yiyi, what are the contents of your PowerShell profiles? It seems like you have something running in your profile that's causing it to hang.

@andyleejordan andyleejordan added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Triage Maintainer attention needed! labels Oct 4, 2022
@memory-yiyi
Copy link
Author

I have not modified the configuration file. I always use the default configuration. Through your reminder, we are checking whether it is due to module update. It may be caused by the module of SQL Server. After all, there will be no problem if the network is not connected

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Oct 5, 2022
@memory-yiyi
Copy link
Author

I think this may be the problem of module update.
There is no problem after reinstalling the system, which indicates that the plug-in is OK. Since the powershell was installed through the application store before, I did not care about the configuration of environment variables, which resulted in the inability to use nuget, that is, the module cannot be updated through it.
If the plug-in will update the module during initialization, please add an option to allow it to be selected. If not, please let me know so that I can continue the analysis.

@andyleejordan
Copy link
Member

Hey you know, it doesn't auto-update modules but it does try to query GitHub to see if PowerShell needs an update. I don't know if that's causing your issue, but you can try disabling it with the setting powershell.promptToUpdatePowerShell (and I just checked, despite the name, this does indeed skip checking if there's an update in the first place).

@memory-yiyi
Copy link
Author

You know, I have executed Fresh Start.
This option has no effect and is almost the same configuration. Only Windows is updated (from 22622.601 to 22623.730) and the SQL server module is not installed.
If this is a problem with Windows, let's end the discussion. However, before we do, we would like you to check the relevant configuration, such as whether the plug-in works normally after the psmodulepath is not configured and the module is installed.
Because this situation really occurs after installing the sqlserver module, I have and only have this external module, and I know that I have not configured psmodulepath at all, that is, pwsh has not configured it, so it may use the powershell5 module.
If you are sure that this is not the problem, we can end the discussion, because I have executed Fresh Start, and the environment has been refreshed, so it is difficult to do research.

@andyleejordan
Copy link
Member

andyleejordan commented Oct 7, 2022

Came out this time, hope it's useful.
EditorServices.log

😬 I just saw this, and looked at your log. Found something very interesting. First off, your log indicates you're starting PowerShell 7, installed from the Windows store, that should be fine, except then I see your PSModulePath is this:

[DBG] Updated PSModulePath to: 'C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;D:\Personal Tools\pwsh\Modules;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules;C:\Users\stardust\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.powershell_7.2.6.0_x64__8wekyb3d8bbwe\Modules;c:\Users\stardust.vscode\extensions\ms-vscode.powershell-2022.8.5\modules'

So you have PowerShell 7 (which is PowerShell Core) for some reason loading modules from PowerShell 5.1 (which is Windows PowerShell). That's not going to work. It makes me think of this issue. The PowerShell host used in the extension does not contain a workaround found in the regular PowerShell Core and Windows PowerShell hosts that "sanitizes" the PSModulePath. Apparently it's totally ok and expected for PowerShell Core to have Windows PowerShell module paths in its PSModulePath, so I guess this isn't it 🤷

Can you describe to me how you're starting VS Code, is it perhaps from a PowerShell prompt, like typing in code.exe to launch it, or are you starting it from an app icon?

In a nutshell, as we determined in the issue I just linked, if the PSModulePath environment variable is already set and contains Windows PowerShell module paths, and then PowerShell Core is started by the extension, things just won't work since the new instance of PowerShell Core has incorrect PSModulePath settings.

@andyleejordan
Copy link
Member

Or, @memory-yiyi have you manually set PSModulePath?

@memory-yiyi
Copy link
Author

You know it's impossible. code.exe starts on icon.

PSModulePath is not configured. As you can see:

[DBG] Updated PSModulePath to: ‘C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;D:\Personal Tools\pwsh\Modules;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules;C:\Users\stardust\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.powershell_7.2.6.0_x64__8wekyb3d8bbwe\Modules;c:\Users\stardust.vscode\extensions\ms-vscode.powershell-2022.8.5\modules’

It is worth noting this paragraph:

C:\Users\stardust\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.powershell_7.2.6.0_x64__8wekyb3d8bbwe\Modules;

These are automatically configured (we will not talk about another one after vscode). But they came last, Terminal.exe or pwsh.exe expands at the beginning rather than at the end.

As you know, the priority of environment variables is higher than that of the following ones. If vscode places them behind, the module of powershell5 will be imported first, which is why the Terminal.exe looks normal.

@andyleejordan
Copy link
Member

@SeeminglyScience thinks we should try ruling something else out. Can you try using a version of PowerShell 7 installed not through the Windows Store? The simplest thing to do would be to grab a zip from the PowerShell releases, extract it, and then add a new additional exe in the VS Code settings to point there and try starting a session with that PowerShell.

@andyleejordan andyleejordan added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Maintainer Attention Maintainer attention needed! labels Oct 18, 2022
@memory-yiyi
Copy link
Author

I have reinstalled the system. At present, I use the winget command to install pwsh. I installed it at the system level. The expansion can be used normally, but the problem may still exist.

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Oct 20, 2022
@andyleejordan
Copy link
Member

Let us know!

@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 20, 2022
@andyleejordan andyleejordan added the Needs: Author Feedback Please give us the requested feedback! label Oct 27, 2022
@bryanlavalley-mil
Copy link

bryanlavalley-mil commented Nov 2, 2022

I think I am having the same issue. This is what I found.
image
Text in the middle of the command line doesn't look correct to me.

Edit ... Rolled back to Extension 2022.8.5 and it now works. The same 'Text' exists in the middle of command line.

@andyleejordan
Copy link
Member

@bryanlavalley-mil you've got -WaitForDebugger in yours, can you check your settings if you have powershell.developer.editorServicesWaitForDebugger enabled?

@memory-yiyi
Copy link
Author

I think the configuration of PSModulePath is wrong. Why do the key ones come to the end? Shouldn't they be on the head?

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Nov 2, 2022
@bryanlavalley-mil
Copy link

@bryanlavalley-mil you've got -WaitForDebugger in yours, can you check your settings if you have powershell.developer.editorServicesWaitForDebugger enabled?

I sure did. Not sure when or how that was checked. I removed and update extension to 2022.10.0 and it still loads. Thanks!

@andyleejordan
Copy link
Member

Ok @memory-yiyi I'm going to mark this as resolved as I think we narrowed the problem down to the Windows Store installation. Let me know if you're still having an issue!

@andyleejordan andyleejordan added Resolution-Answered Will close automatically. and removed Needs: Maintainer Attention Maintainer attention needed! labels Nov 22, 2022
@memory-yiyi
Copy link
Author

OK, thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants