Skip to content

Command 'python.analysis.restartLanguageServer' already exists #13441

Closed

Description

  • Issue Type: Bug
  • Extension Name: python
  • Extension Version: 2020.8.101144
  • OS Version: Darwin x64 19.6.0
  • VSCode version: 1.48.0
{
	"messages": [],
	"activationTimes": {
		"codeLoadingTime": 966,
		"activateCallTime": 367,
		"activateResolvedTime": 2853,
		"activationReason": {
			"startup": false,
			"extensionId": {
				"value": "ms-python.python",
				"_lower": "ms-python.python"
			},
			"activationEvent": "onLanguage:python"
		}
	},
	"runtimeErrors": [
		{
			"name": "Error",
			"message": "command 'python.analysis.restartLanguageServer' already exists"
		}
	]
}

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Aug 14, 2020
  2. changed the title [-]Extension :warning:[/-] [+]Extension Bug[/+] on Aug 14, 2020
  3. yousefabuz17 commented on Aug 15, 2020

    @yousefabuz17

    Python 2020.8.101144 has many bugs, downgrade it to the one below it and everything should be fine. I issued a bug where the terminal would not accept any keyboard inputs and took me so long to realize what happened and its because python has a very recent update and downgrading it worked.

  4. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Aug 17, 2020
  5. changed the title [-]Extension Bug[/-] [+]Extension Bug: command 'python.analysis.restartLanguageServer' already exists[/+] on Aug 17, 2020
  6. kimadeline commented on Aug 18, 2020

    @kimadeline

    Hi Haden Moore (@HadenMoore), thank you for reaching out!

    Does this behaviour happen consistently, and would yousefabuz17 downgrading suggestion work as a workaround for now?

    I couldn't reproduce your issue on macOS 10.15.6, VS Code 1.48.0 and the Python extension 2020.8.101144, what is the value of the python.languageServer setting in your user settings?

    Thank you!

  7. leonhx commented on Sep 23, 2020

    @leonhx

    Hi Kim-Adeline Miguel (@kimadeline) , I can constantly reproduce this issue: firstly add multiple folders to a workspace, open a file in one folder, then switch to a file from another folder(it is the key point), then an error occurs:

    Error 2020-09-23 17:04:23: Failed to activate a workspace, Class name = v, completed in 254ms, has a falsy return value, Arg 1: <Uri:/Users/xxx/Developer/xxx>, Return Value: undefined [Error: command 'python.analysis.restartLanguageServer' already exists
    	at _.registerCommand (/Users/xxx/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:674:270)
    	at Object.registerCommand (/Users/xxx/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:977:119)
    	at s.registerCommand (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:54:495185)
    	at new r (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:54:178371)
    	at Object.t.resolveInstance (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:265970)
    	at /Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:265172
    	at Array.map (<anonymous>)
    	at Object.t.resolveInstance (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:265740)
    	at /Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:265172
    	at Object.t.resolve (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:265439)
    	at /Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:256520
    	at e._get (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:256286)
    	at e.getTagged (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:255088)
    	at e.getNamed (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:255180)
    	at a.get (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:1055572)
    	at C.createRefCountedServer (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:303140)
    	at async C.activate (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:301001)
    	at async Promise.all (index 4)
    	at async v.activateWorkspace (/Users/xxx/.vscode/extensions/ms-python.python-2020.8.109390/out/client/extension.js:47:296083)]
    

    Version: 1.49.1
    Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
    Date: 2020-09-16T23:21:17.533Z (6 days ago)
    Electron: 9.2.1
    Chrome: 83.0.4103.122
    Node.js: 12.14.1
    V8: 8.3.110.13-electron.0
    OS: Darwin x64 19.6.0
    ms-python: v2020.8.109390

  8. kimadeline commented on Sep 24, 2020

    @kimadeline

    Hi (Leon) X. Huang (@leonhx),

    Do you have a sample repo I could use to reproduce the issue, because I did not experience this issue with the steps you outlined:

    multiroot

    What is what is the value of the python.languageServer setting in your user settings and your workspace? Could you also copy the logs of the Python output channel?

    Thanks!

  9. leonhx commented on Sep 28, 2020

    @leonhx

    Kim-Adeline Miguel (@kimadeline) , your GIF showed exactly what I meant. In my settings, "python.languageServer": "Microsoft". My workspace has no custom settings.

    Here's a more specific reproduce procedure:

    After the above steps finished, the logs from Python channel are:

    User belongs to experiment group 'AlwaysDisplayTestExplorer - control'
    User belongs to experiment group 'ShowPlayIcon - start'
    User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
    User belongs to experiment group 'DebugAdapterFactory - experiment'
    User belongs to experiment group 'PtvsdWheels37 - experiment'
    User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
    User belongs to experiment group 'AA_testing - control'
    User belongs to experiment group 'LocalZMQKernel - experiment'
    User belongs to experiment group 'CollectLSRequestTiming - control'
    User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
    User belongs to experiment group 'EnableIPyWidgets - experiment'
    User belongs to experiment group 'DeprecatePythonPath - experiment'
    User belongs to experiment group 'RunByLine - control'
    User belongs to experiment group 'CustomEditorSupport - control'
    Error 2020-09-28 16:21:51: Failed to initialize source map support in extension
    User belongs to experiment group 'pythonaacf'
    > conda --version
    > pyenv root
    > python3.7 ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
    > python3.6 ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
    > python3 ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
    > python2 ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
    > python ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
    > python ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
    > conda info --json
    > conda info --json
    > conda info --json
    > conda env list
    Error 2020-09-28 16:21:53: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file '/Users/xxxx/Developer/github.com/ENSFM/.vscode/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/Users/xxxx/Developer/github.com/ENSFM/.vscode/settings.json')
    	at _handleError (/Users/xxxx/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:706:74)
    	at runMicrotasks (<anonymous>)
    	at processTicksAndRejections (internal/process/task_queues.js:94:5)
    	at async y.readText (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:1:498595)
    	at async p.doesFileNeedToBeFixed (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:56:960982)
    	at async /Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:56:960109
    	at async Promise.all (index 1)
    	at async p.getFilesToBeFixed (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:56:960055)
    	at async p.updateTestSettings (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:56:959682)] {
      code: 'FileNotFound',
      name: 'EntryNotFound (FileSystemError)'
    }
    > conda env list
    Starting Microsoft Python language server.
    Python interpreter path: /usr/local/anaconda3/envs/kaggle/bin/python
    > /usr/local/anaconda3/envs/easytf_dev/bin/python ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
    > /usr/local/anaconda3/envs/easytf_dev/bin/python ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
    > /usr/local/anaconda3/envs/easytf_dev/bin/python ~/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py jupyter kernelspec --version
    Starting Microsoft Python language server.
    Error 2020-09-28 16:22:25: Failed to activate a workspace, Class name = y, completed in 230ms, has a falsy return value, Arg 1: <Uri:/Users/xxxx/Developer/github.com/facebook-DLRM>, Return Value: undefined [Error: command 'python.analysis.restartLanguageServer' already exists
    	at _.registerCommand (/Users/xxxx/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:674:270)
    	at Object.registerCommand (/Users/xxxx/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:977:119)
    	at s.registerCommand (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:54:373547)
    	at new r (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:54:51397)
    	at Object.t.resolveInstance (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:266184)
    	at /Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:265386
    	at Array.map (<anonymous>)
    	at Object.t.resolveInstance (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:265954)
    	at /Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:265386
    	at Object.t.resolve (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:265653)
    	at /Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:256734
    	at e._get (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:256500)
    	at e.getTagged (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:255302)
    	at e.getNamed (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:255394)
    	at a.get (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:56:1063072)
    	at C.createRefCountedServer (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:303871)
    	at async C.activate (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:301732)
    	at async Promise.all (index 4)
    	at async y.activateWorkspace (/Users/xxxx/.vscode/extensions/ms-python.python-2020.9.111407/out/client/extension.js:47:296814)]
    

    Environment:

    Version: 1.49.2
    Commit: e5e9e69aed6e1984f7499b7af85b3d05f9a6883a
    Date: 2020-09-24T16:23:52.277Z
    Electron: 9.2.1
    Chrome: 83.0.4103.122
    Node.js: 12.14.1
    V8: 8.3.110.13-electron.0
    OS: Darwin x64 19.6.0
    ms-python: v2020.9.111407
    
  10. 6 remaining items

  11. jakebailey commented on Sep 28, 2020

    @jakebailey
    Member

    Here. The entire implementation of this command is in the core extension. These commands are unknown to any LS directly, as the core extension manages the entire lifetime of the LS. #12952

    The command gets registered in the LS manager. There should only be one of those at as time depending on the LS setting choice. I'm not sure how it's possible without some violation of the injection system.

  12. kimadeline commented on Sep 28, 2020

    @kimadeline

    Yeah, I don't know how that happens either. Maybe something to do with multi-root workspaces and being called for each workspace?

    In any case, it doesn't happen when using Pylance.

  13. changed the title [-]Extension Bug: command 'python.analysis.restartLanguageServer' already exists[/-] [+]Command 'python.analysis.restartLanguageServer' already exists when using MPLS[/+] on Sep 28, 2020
  14. rchiodo commented on Nov 13, 2020

    @rchiodo

    We get this on our smoke tests now.

    https://github.com/microsoft/vscode-jupyter/runs/1398220329?check_suite_focus=true

    It seems like it would happen when switching language servers if you don't restart.

  15. jakebailey commented on Nov 13, 2020

    @jakebailey
    Member

    My patch that added this adds the command disposal, but it's likely that it's not actually getting disposed for some reason. Maybe it needs to be shoved down further so that it can only be available when the LS is running.

  16. joyceerhl commented on Nov 18, 2020

    @joyceerhl

    In the meantime maybe we could work around this in the commandRegistry by ensuring we call registerCommand once for each command? i.e. the commandRegistry would cache commands that it's already registered.

  17. jakebailey commented on Nov 18, 2020

    @jakebailey
    Member

    The problem would be if the old command is referencing a dead LS client, and therefore does nothing. I suppose that this is rare though where you need to change a setting (and are already in a bad state) and reload, so maybe it's not a huge problem.

  18. joyceerhl commented on Nov 18, 2020

    @joyceerhl

    Followed the repro steps above (set language server to 'Microsoft', cloned the two repos, opened a Python file from each). It seems like what's happening is the following:

    • ILanguageServerManager is not added as a singleton to the service container
    • When the user opens the second folder, a new instance of the ILanguageServerManager is created
    • This causes the constructor to be called twice
    • The command gets registered twice

    I debugged this locally and can verify that the constructor was called twice, and that's likely the source of the duplicate command registrations. Can the ILanguageServerManager be made a singleton? If a new one really needs to be created per folder in a workspace, the command may need to be registered elsewhere.

  19. jakebailey commented on Nov 18, 2020

    @jakebailey
    Member

    It can't be a singleton due to multi-root (one MPLS per root), but that's been broken for a while. The individual LS is what needs to be restarted, so having more than one technically breaks that down because you have to ask "which LS to restart". It's likely my implementation was too simple and needed to go and restart every running LS or something, and register the command elsewhere.

  20. joyceerhl commented on Nov 18, 2020

    @joyceerhl

    needed to go and restart every running LS or something, and register the command elsewhere.

    Yeah that makes sense, or maybe figure out which LS to restart based on the active root. In any case this error isn't fatal for our smoke tests so we don't urgently need a fix.

  21. mfdeveloper commented on Feb 1, 2021

    @mfdeveloper

    +1 Kim-Adeline Miguel (@kimadeline) solution about use Pylance works!! But, I think that "python.languageServer": "Microsoft" should work as well, right?

  22. changed the title [-]Command 'python.analysis.restartLanguageServer' already exists when using MPLS[/-] [+]Command 'python.analysis.restartLanguageServer' already exists[/+] on Apr 29, 2021
  23. locked as resolved and limited conversation to collaborators on May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions