Skip to content
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

Error: command 'pyright.createtypestub' already exists #2765

Closed
shaunm-msft opened this issue May 3, 2022 · 96 comments
Closed

Error: command 'pyright.createtypestub' already exists #2765

shaunm-msft opened this issue May 3, 2022 · 96 comments
Assignees
Labels
bug Something isn't working external bug

Comments

@shaunm-msft
Copy link

[Info - 7:56:43 AM] (46164) Pylance language server 2022.4.4-pre.1 (pyright 88f2a424) starting
[Info - 7:56:43 AM] (46164) Server root directory: c:\Users\shaunm.vscode-insiders\extensions\ms-python.vscode-pylance-2022.4.4-pre.1\dist
[Error - 7:56:43 AM] Server initialization failed.
Error: command 'pyright.createtypestub' already exists
at o.registerCommand (c:\Users\shaunm\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:83:29716)
at Object.registerCommand (c:\Users\shaunm\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:97:30972)
at t.ExecuteCommandFeature.register (c:\Users\shaunm.vscode-insiders\extensions\ms-python.python-2022.5.11231003\out\client\extension.js:2:2220058)
at t.ExecuteCommandFeature.initialize (c:\Users\shaunm.vscode-insiders\extensions\ms-python.python-2022.5.11231003\out\client\extension.js:2:2219637)
at S.initializeFeatures (c:\Users\shaunm.vscode-insiders\extensions\ms-python.python-2022.5.11231003\out\client\extension.js:2:2172202)
at S.doInitialize (c:\Users\shaunm.vscode-insiders\extensions\ms-python.python-2022.5.11231003\out\client\extension.js:2:2160126)
at async S.start (c:\Users\shaunm.vscode-insiders\extensions\ms-python.python-2022.5.11231003\out\client\extension.js:2:2157141)
at async f.start (c:\Users\shaunm.vscode-insiders\extensions\ms-python.python-2022.5.11231003\out\client\extension.js:2:34030)
[Error - 7:56:43 AM] Python Tools client: couldn't create connection to server.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python May 3, 2022
@github-actions github-actions bot added the triage label May 3, 2022
@judej judej added the needs investigation Could be an issue - needs investigation label May 3, 2022
@github-actions github-actions bot removed the triage label May 3, 2022
@judej
Copy link
Contributor

judej commented May 3, 2022

Thanks for the report. This can happen if Pyright and Pylance extensions are both installed. Is this the case for you? If so, could you please uninstall one of them?

@judej judej removed the classify label May 3, 2022
@debonte
Copy link
Contributor

debonte commented May 4, 2022

Discussed this with Eric today. When both Pyright and Pylance are installed, Pyright will detect that Pylance is present and disable itself. Best guess is that this exception happens in cases where Pyright is already installed and the user installs Pylance after Pyright has activated.

In any case, nothing has changed with this logic on our side recently. But there has clearly been a change in behavior since we've seen this exception in our stack traces over the past couple weeks and now a user has reported it.

Our theory is that the LSP 3.17 upgrade included a change to throw an exception when an extension attempts to register an already registered command, whereas it used to be silent. Plan is to just catch the exception.

@shaunm-msft
Copy link
Author

I have the Pylance extension installed but not the Pyright extension. That is to say, the pyright extension doesn't appear in the list of installed extensions and it doesn't appear in the list of running extensions.

@debonte
Copy link
Contributor

debonte commented May 4, 2022

I have the Pylance extension installed but not the Pyright extension.

Wow, ok. Can you send us a list of the extensions you have installed? You can dump the list of extensions on the command line using code --list-extensions

@shaunm-msft
Copy link
Author

E:>code-insiders --list-extensions
ms-dotnettools.vscode-dotnet-runtime
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-vscode-remote.remote-wsl
ms-vscode.cpptools
ms-vscode.powershell-preview
VisualStudioExptTeam.intellicode-api-usage-examples
VisualStudioExptTeam.vscodeintellicode-completions
VisualStudioExptTeam.vscodeintellicode-insiders

@Sanqui
Copy link

Sanqui commented May 6, 2022

Also ran into this problem today after setting up a new VS Code instance and syncing my settings. Here's my list of extensions:

sanqui@myrtus ~> code --list-extensions
eamodio.gitlens
gerane.Theme-Cobalt
HookyQR.beautify
jock.svg
ms-azuretools.vscode-docker
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode.cpptools
RandomFractalsInc.vscode-data-preview
RoscoP.fastbuild
samuelcolvin.jinjahtml
svelte.svelte-vscode
wesbos.theme-cobalt2

Version: Pylance language server 2022.4.3 (pyright 88f2a424)

@Finerestaurant
Copy link

Finerestaurant commented May 6, 2022

I also head same probelm after changing conda virtual environment. Here's my extension lists.

(base) C:\Users\user>code --list-extensions
cschlosser.doxdocgen
Equinusocio.vsc-community-material-theme
Equinusocio.vsc-material-theme
equinusocio.vsc-material-theme-icons
jeff-hykin.better-cpp-syntax
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode.cmake-tools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
oderwat.indent-rainbow
twxs.cmake

@arsenie-ciobanu-cko
Copy link

Same thing here - just installed VS Code and getting this error:

[Error - 3:47:25 PM] Pylance client: couldn't create connection to server.
Error: command 'pyright.createtypestub' already exists

Version: Pylance language server 2022.4.3 (pyright 88f2a424)

here's my extensions list:

user@xxx ~ % code --list-extensions
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers

@55octet
Copy link

55octet commented May 6, 2022

Same issue:

code --list-extensions
eamodio.gitlens
michelemelluso.gitignore    
ms-python.python
ms-python.vscode-pylance    
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap   
ms-toolsai.jupyter-renderers

@thomas-oconnell
Copy link

thomas-oconnell commented May 7, 2022

Reverting to Python extension version 2022.4.1 from 2022.6.0 resolved this issue for me, though your mileage may vary. I did not touch the Pylance extension version.

With version 2022.6.0, the issue wouldn't appear as long as I had a project folder open and contained my work in that regard.

With version 2022.4.1, the issue was gone, regardless of my current working status.

Edit: corrected "very" to "vary" - long workdays :)

@netcore-jroger
Copy link

Reverting to Python extension version 2022.4.1 from 2022.6.0 resolved this issue for me, though your mileage may very. I did not touch the Pylance extension version.

With version 2022.6.0, the issue wouldn't appear as long as I had a project folder open and contained my work in that regard.

With version 2022.4.1, the issue was gone, regardless of my current working status.

how to download 2022.4.1 version.

@thomas-oconnell
Copy link

Reverting to Python extension version 2022.4.1 from 2022.6.0 resolved this issue for me, though your mileage may very. I did not touch the Pylance extension version.
With version 2022.6.0, the issue wouldn't appear as long as I had a project folder open and contained my work in that regard.
With version 2022.4.1, the issue was gone, regardless of my current working status.

how to download 2022.4.1 version.

Click on the extension within VS Code, click the arrow next to Uninstall, then "Install Another Version..."

@Angshuman-Maity
Copy link

Angshuman-Maity commented May 7, 2022

I was also facing the same issue. Reverting back to Python extension version 2022.4.1 from 2022.6.0 resolved this issue for me. Thank you .

@erictraut
Copy link
Contributor

Thanks for the update. Based on these clues, this looks like it's probably a regression in the core Python extension. I wonder if the Python extension is unloading and then reloading Pylance but doing so in a way that the command 'pyright.createtypestub' isn't unregistered upon unload.

@BobDenny
Copy link

BobDenny commented May 7, 2022

Same here, reverted to 2022.4.1 cured it also. Thank you @thomas-oconnell

> code --list-extensions
aaron-bond.better-comments
Cameron.vscode-pytest
DavidAnson.vscode-markdownlint
dawhite.mustache
dbaeumer.vscode-eslint
donjayamanne.python-environment-manager
DotJoshJohnson.xml
eamodio.gitlens
Equinusocio.vsc-material-theme
equinusocio.vsc-material-theme-icons
formulahendry.code-runner
ms-python.python
ms-python.vscode-pylance
nico-castell.linux-desktop-file
njpwerner.autodocstring
rangav.vscode-thunder-client
redhat.vscode-yaml
slightc.pip-manager
tomblind.local-lua-debugger-vscode
tomoki1207.pdf
trond-snekvik.simple-rst

@trinatek
Copy link

trinatek commented May 8, 2022

Samesies:

code --list-extensions
akamud.vscode-theme-onedark
almenon.arepl
arcsector.vscode-splunk-search-linter
arcsector.vscode-splunk-search-syntax
cantonios.project-templates
DotJoshJohnson.xml
emilast.LogFileHighlighter
formulahendry.auto-rename-tag
KevinRose.vsc-python-indent
mgesbert.python-path
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-vscode-remote.remote-wsl
ms-vscode.powershell
PKief.material-icon-theme
PrateekMahendrakar.prettyxml
richie5um2.vscode-sort-json
ryuta46.multi-command
seanwu.vscode-qt-for-python
Splunk.splunk
stkb.rewrap
vscodevim.vim
zhuangtongfa.material-theme
Zignd.html-css-class-completion

I can also report that switching back to VS Code Python Extension v2022.04.01 resolved the issue for the time-being.
(Right-click the extension on the VSCode side bar -> 'Install Another Version...' )

@shendin-chrobinson
Copy link

I have experienced the same today, and downgrading the core Python extension to v2022.4.1 fixed it for me.

@zachsiegel-capsida
Copy link

Same issue, reverting Python core version solved it for me too.

@BobDenny
Copy link

BobDenny commented May 9, 2022

I just updated to the 2022.7.11291008 Pre-Release version and the problem is also gone.

@progrunman
Copy link

I'm also v2022.6.0 and the problem occurred after moving the source folder of the existing project. The problem went away when I restarted VSCode after a few minutes. However, the warning below is still occurring.

[Warn] (14348) stubPath 'my project folder path'\typings is not a valid directory.

The 'typings' folder was not created by me and does not exist in the my source folder. So, I don't know what that is.

@Kein
Copy link

Kein commented May 10, 2022

Same issue.
I have 3 versions of Python installed, 3.9.6, 3.10 and 3.8.5 but only switching to 3.8.5 causes this issue.

@edwardchoijc
Copy link

edwardchoijc commented May 11, 2022

Same issue. My full log is below.

[Info - 11:30:50 AM] (78228) Pylance language server 2022.4.3 (pyright 88f2a424) starting
[Info - 11:30:50 AM] (78228) Server root directory: /HOME_PATH/.vscode/extensions/ms-python.vscode-pylance-2022.4.3/dist
[Warn - 11:30:50 AM] (78228) stubPath /MY_PROJECT_PATH/typings is not a valid directory.
[Info - 11:31:08 AM] (78246) Pylance language server 2022.4.3 (pyright 88f2a424) starting
[Info - 11:31:08 AM] (78246) Server root directory: /HOME_PATH/.vscode/extensions/ms-python.vscode-pylance-2022.4.3/dist
[Error - 11:31:08 AM] Server initialization failed.
Error: command 'pyright.createtypestub' already exists
at o.registerCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:83:29716)
at Object.registerCommand (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:97:30972)
at t.ExecuteCommandFeature.register (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2221856)
at t.ExecuteCommandFeature.initialize (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2221435)
at S.initializeFeatures (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2174000)
at S.doInitialize (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2161924)
at async S.start (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2158939)
at async S.$start (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2165739)
at async t.Delayer. (/HOME_PATH/.vscode/extensions/ms-python.python-2022.6.1/out/client/extension.js:2:2164010)
[Error - 11:31:08 AM] Pylance client: couldn't create connection to server.

Extensions:

code --list-extensions
2gua.rainbow-brackets
aaron-bond.better-comments
alefragnani.project-manager
DotJoshJohnson.xml
eamodio.gitlens
Equinusocio.vsc-community-material-theme
Equinusocio.vsc-material-theme
equinusocio.vsc-material-theme-icons
GrapeCity.gc-excelviewer
KevinRose.vsc-python-indent
Lencerf.beancount
mhutchie.git-graph
MS-CEINTL.vscode-language-pack-zh-hans
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-vscode-remote.remote-wsl
njpwerner.autodocstring
Shan.code-settings-sync
Tyriar.sort-lines
vscode-icons-team.vscode-icons

And I found a very strange problem, that is, with the same environment, only some projects had this situation, which is the other projects had not.

@judej judej added bug Something isn't working and removed bug Something isn't working labels Mar 28, 2023
@lexi-the-cute
Copy link

lexi-the-cute commented Apr 5, 2023

I'll have to double check with the absolute latest version of PyLance when I get time to look into this. I had this happen on version v2023.3.40 and I don't have PyRight installed.

Edit: So, I'm not sure how PyRight is installed given that it shows as uninstalled in vs-code. The VS-Code version was 1.77.0-1680085573. The error was command 'pyright.createtypestub' already exists. I just updated to 1.77.1-1680651665 so I'll have to see if the issue still exists.

@heejaechang
Copy link
Contributor

@alexisart the fix is being tested using A/B test. you can try setting this hidden option python.analysis.pylanceLspClientEnabled and see whether it still repro. make sure to use latest prerelease.

@2victor2
Copy link

2victor2 commented Apr 11, 2023

@alexisart the fix is being tested using A/B test. you can try setting this hidden option python.analysis.pylanceLspClientEnabled and see whether it still repro. make sure to use latest prerelease.

I'm in similar scenario as @alexisart and after setting python.analysis.pylanceLspClientEnabled and changing Python extension to pre-release as recommended it worked.

Edit: It is working with this setting on version v2023.6.0.

@CarlGao4
Copy link

Mine is not working.

> code -v
1.77.3
704ed70d4fd1c6bd6342c436f1ede30d1cff4710
x64
> code --list-extensions --show-versions
MS-CEINTL.vscode-language-pack-zh-hans@1.77.2023040509
ms-python.python@2023.6.0
ms-python.vscode-pylance@2023.4.30

@heejaechang
Copy link
Contributor

@CarlGao4 after setting python.analysis.pylanceLspClientEnabled? if so, can you give us repro steps?

@CarlGao4
Copy link

@CarlGao4 after setting python.analysis.pylanceLspClientEnabled? if so, can you give us repro steps?

I realized that only some of the times when I start VSCode will encounter this, both using version 2023.6.0 and 2023.6.1
But only the first time I opened VSCode after setting python.analysis.pylanceLspClientEnabled got the error. Then it is ok.

@heejaechang
Copy link
Contributor

@CarlGao4 when you said opened VSCode after setting the option, you meant close and open vscode? or window reload? or something else?

@CarlGao4
Copy link

Close and open it. I haven't encounter this issue since I upgraded to the pre-release and set python.analysis.pylanceLspClientEnabled

@zzzeek
Copy link

zzzeek commented May 9, 2023

hi there -

in the past two weeks ive begun to get this issue constantly, I've been over in #4318 and it appears my issue was mis-diagnosed. It looks like this is an ongoing issue. Will try turning on python.analysis.pylanceLspClientEnabled.

@rchiodo
Copy link
Contributor

rchiodo commented May 9, 2023

python.analysis.pylanceLspClientEnabled requires prerelease versions of Python and Pylance extension.

@zzzeek
Copy link

zzzeek commented May 9, 2023

yup so far so good will keep you posted

@StijnvanderLippe
Copy link

The issue still occurs for me, but not always. Sometimes it happens on initial startup (after booting my laptop), or when closing VS Code and reopening the window. I am using the prerelease version of both the Python and Pylance extension, and the option "Python › Analysis: Pylance Lsp Client Enabled" is ticked on.

@zzzeek
Copy link

zzzeek commented May 16, 2023

ive seen no failures at all since applying the new parameter.

@heejaechang
Copy link
Contributor

@StijnvanderLippe are you using the latest version of python/pylance extension?

@StijnvanderLippe
Copy link

@heejaechang I am using Pylance pre-release v2023.5.21 and Python pre-release v2023.9.11361009.

By the way: I opened VS Code to check the version numbers. First start up: no issue. Just to check, I close VS Code (simply by clicking the x in the top right corner of the window) and re-open and I get the error messages. Subsequently closing and reopening VS Code brings up the error messages every time.

@heejaechang
Copy link
Contributor

@StijnvanderLippe Can you provide us some logs as described in the troubleshooting guide?

I want to check that new client is actually enabled for us.

@StijnvanderLippe
Copy link

I am using a virtual environment with Python 3.10.11.

Note that this is not the full log, because the output seemed to include the whole source code for vendor.bundle.js to indicate where an error occurred. But it didn't have any formatting, so it was just thousands of lines of code.

log.txt

@heejaechang
Copy link
Contributor

thank you! let me take a look!

@heejaechang
Copy link
Contributor

one more question, the folder/workspace you are using? is it trusted workspace or untrusted workspace?

@StijnvanderLippe
Copy link

It is a trusted workspace.

Also, when I went to open VS Code to check this, I got no error messages. I did not reboot my machine in the mean time. When I reopened shortly after, I get the error messages again.

@heejaechang
Copy link
Contributor

can I ask you one more question, if you give it a little bit of time say 15 seconds once you closed the vscode before you reopen vscode does it still happen? trying to figure out whether there is a race between shutting down server and restarting a server

@StijnvanderLippe
Copy link

StijnvanderLippe commented May 17, 2023

Bad news, when I started up VS Code for the first time after booting my machine, the error messages popped up as well. So that is confusing.

I tried various different delays: 10 seconds, 30 seconds, a minute, 3 minutes, and 5 minutes but every time the error messages pop up when opening VS Code again. Some of the times when I reopened VS Code I got slightly different error messages, see attached log messages.
log.txt

I waited 10 minutes and then no error message popped up when opening VS Code again. Closing and restarting quickly after this initially gave no error messages, but closing and restarting the second time did bring up the messages.

I waited 10 minutes again, and no error messages popped up when opening VS Code. Closing and restarting quickly did bring up the messages.

@kielnino
Copy link

This also happens to me. For me it started after I accidentally installed the pyright extension because I didn't know that the functionality is already included in pylance. After I uninstalled the pyright extension the error messages appear now.

@willjhenry
Copy link

Same, happening to me on Visual Studio Code - Insider, and pylance 2023.6.10

@heejaechang
Copy link
Contributor

we didn't get any issue over this for long time now. closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external bug
Projects
None yet
Development

No branches or pull requests