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

Is there any plan to migrate pygls to v2.0? #546

Open
Snoopy1866 opened this issue Oct 12, 2024 · 5 comments
Open

Is there any plan to migrate pygls to v2.0? #546

Snoopy1866 opened this issue Oct 12, 2024 · 5 comments
Labels
debt Technical debt or repo cleanup needs PR upstream Issue is in a dependency

Comments

@Snoopy1866
Copy link

Snoopy1866 commented Oct 12, 2024

I'm using black formatter and esbonio simutaniously. I found the pre-release of esbonio has updated the pygls to 2.0.0a1, which is incompatible with black formatter.

pygls v2.0.0a1 cause Black Formatter server crashed 5 times in the last 3 minutes, same as #189

Below is the output:

2024-10-12 13:58:17.199 [info] Server run command: c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower\.venv\Scripts\python.exe c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py
2024-10-12 13:58:17.199 [info] Server: Start requested.
2024-10-12 13:58:17.480 [info] Traceback (most recent call last):

2024-10-12 13:58:17.480 [info]   File "c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py", line 76, in <module>
    LSP_SERVER = server.LanguageServer(
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pygls.server' has no attribute 'LanguageServer'

2024-10-12 13:58:17.646 [info] [Error - 13:58:17] Server process exited with code 1.
2024-10-12 13:58:17.647 [info] [Error - 13:58:17] Server initialization failed.
2024-10-12 13:58:17.647 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
Full output
2024-10-12 13:58:17.199 [info] Name: Black Formatter
2024-10-12 13:58:17.199 [info] Module: black
2024-10-12 13:58:17.199 [info] Default formatter is set to ms-python.black-formatter for workspace c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower
2024-10-12 13:58:17.199 [info] Python extension loading
2024-10-12 13:58:17.199 [info] Waiting for interpreter from python extension.
2024-10-12 13:58:17.199 [info] No interpreter found from setting black-formatter.interpreter
2024-10-12 13:58:17.199 [info] Getting interpreter from ms-python.python extension for workspace c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower
2024-10-12 13:58:17.199 [info] Python extension loaded
2024-10-12 13:58:17.199 [info] Interpreter from ms-python.python extension for c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower: c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower\.venv\Scripts\python.exe
2024-10-12 13:58:17.199 [info] Workspace settings for c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower (client side): {
    "cwd": "c:\\Users\\wtwang\\Documents\\GitHub\\PyStatPower\\PyStatPower",
    "workspace": "file:///c%3A/Users/wtwang/Documents/GitHub/PyStatPower/PyStatPower",
    "args": [],
    "path": [],
    "interpreter": [
        "c:\\Users\\wtwang\\Documents\\GitHub\\PyStatPower\\PyStatPower\\.venv\\Scripts\\python.exe"
    ],
    "importStrategy": "fromEnvironment",
    "showNotifications": "always"
}
2024-10-12 13:58:17.199 [info] No interpreter found from setting black-formatter.interpreter
2024-10-12 13:58:17.199 [info] Getting interpreter from ms-python.python extension for workspace c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower
2024-10-12 13:58:17.199 [info] Interpreter from ms-python.python extension for c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower: c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower\.venv\Scripts\python.exe
2024-10-12 13:58:17.199 [info] Workspace settings for c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower (client side): {
    "cwd": "c:\\Users\\wtwang\\Documents\\GitHub\\PyStatPower\\PyStatPower",
    "workspace": "file:///c%3A/Users/wtwang/Documents/GitHub/PyStatPower/PyStatPower",
    "args": [],
    "path": [],
    "interpreter": [
        "c:\\Users\\wtwang\\Documents\\GitHub\\PyStatPower\\PyStatPower\\.venv\\Scripts\\python.exe"
    ],
    "importStrategy": "fromEnvironment",
    "showNotifications": "always"
}
2024-10-12 13:58:17.199 [info] Global settings (client side): {
    "cwd": "C:\\Users\\wtwang\\AppData\\Local\\Programs\\Microsoft VS Code",
    "workspace": "C:\\Users\\wtwang\\AppData\\Local\\Programs\\Microsoft VS Code",
    "args": [],
    "path": [],
    "interpreter": [],
    "importStrategy": "fromEnvironment",
    "showNotifications": "always"
}
2024-10-12 13:58:17.199 [info] Server run command: c:\Users\wtwang\Documents\GitHub\PyStatPower\PyStatPower\.venv\Scripts\python.exe c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py
2024-10-12 13:58:17.199 [info] Server: Start requested.
2024-10-12 13:58:17.480 [info] Traceback (most recent call last):

2024-10-12 13:58:17.480 [info]   File "c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py", line 76, in <module>
    LSP_SERVER = server.LanguageServer(
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pygls.server' has no attribute 'LanguageServer'

2024-10-12 13:58:17.646 [info] [Error - 13:58:17] Server process exited with code 1.
2024-10-12 13:58:17.647 [info] [Error - 13:58:17] Server initialization failed.
2024-10-12 13:58:17.647 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:17.647 [info] [Info  - 13:58:17] Connection to server got closed. Server will restart.
2024-10-12 13:58:17.647 [info] true
2024-10-12 13:58:17.648 [info] [Error - 13:58:17] Black Formatter client: couldn't create connection to server.
2024-10-12 13:58:17.648 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:18.386 [info] Traceback (most recent call last):

2024-10-12 13:58:18.386 [info]   File "c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py", line 76, in <module>
    LSP_SERVER = server.LanguageServer(
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pygls.server' has no attribute 'LanguageServer'

2024-10-12 13:58:18.473 [info] [Error - 13:58:18] Server initialization failed.
2024-10-12 13:58:18.473 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:18.473 [info] [Info  - 13:58:18] Connection to server got closed. Server will restart.
2024-10-12 13:58:18.473 [info] true
2024-10-12 13:58:18.473 [info] [Error - 13:58:18] Black Formatter client: couldn't create connection to server.
2024-10-12 13:58:18.473 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:18.473 [error] Server: Start failed: Error: Pending response rejected since connection got disposed
2024-10-12 13:58:18.473 [info] [Error - 13:58:18] Server process exited with code 1.
2024-10-12 13:58:19.416 [info] Traceback (most recent call last):
  File "c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py", line 76, in <module>
    LSP_SERVER = server.LanguageServer(
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pygls.server' has no attribute 'LanguageServer'

2024-10-12 13:58:19.417 [info] [Error - 13:58:19] Server process exited with code 1.
2024-10-12 13:58:19.417 [info] [Error - 13:58:19] Server initialization failed.
2024-10-12 13:58:19.417 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:19.417 [info] [Info  - 13:58:19] Connection to server got closed. Server will restart.
2024-10-12 13:58:19.417 [info] true
2024-10-12 13:58:19.418 [info] [Error - 13:58:19] Black Formatter client: couldn't create connection to server.
2024-10-12 13:58:19.418 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:19.418 [info] [Error - 13:58:19] Restarting server failed
2024-10-12 13:58:19.418 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:20.507 [info] Traceback (most recent call last):
  File "c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py", line 76, in <module>
    LSP_SERVER = server.LanguageServer(
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pygls.server' has no attribute 'LanguageServer'

2024-10-12 13:58:20.582 [info] [Error - 13:58:20] Server initialization failed.
2024-10-12 13:58:20.582 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:20.582 [info] [Info  - 13:58:20] Connection to server got closed. Server will restart.
2024-10-12 13:58:20.582 [info] true
2024-10-12 13:58:20.582 [info] [Error - 13:58:20] Black Formatter client: couldn't create connection to server.
2024-10-12 13:58:20.582 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:20.582 [info] [Error - 13:58:20] Restarting server failed
2024-10-12 13:58:20.582 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:20.582 [info] [Error - 13:58:20] Server process exited with code 1.
2024-10-12 13:58:21.040 [info] Traceback (most recent call last):
  File "c:\Users\wtwang\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py", line 76, in <module>
    LSP_SERVER = server.LanguageServer(
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pygls.server' has no attribute 'LanguageServer'

2024-10-12 13:58:21.112 [info] [Error - 13:58:21] Server initialization failed.
2024-10-12 13:58:21.112 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:21.112 [info] [Error - 13:58:21] The Black Formatter server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
2024-10-12 13:58:21.112 [info] [Error - 13:58:21] Black Formatter client: couldn't create connection to server.
2024-10-12 13:58:21.112 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:21.112 [info] [Error - 13:58:21] Restarting server failed
2024-10-12 13:58:21.112 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-10-12 13:58:21.112 [info] [Error - 13:58:21] Server process exited with code 1.

I wonder if there is a plan of migrating pygls to v2.0?

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Oct 12, 2024
@Snoopy1866
Copy link
Author

Snoopy1866 commented Oct 12, 2024

I see the LanguageServer class has been moved to the pygls.lsp module, may be that's the point of crushing.

https://pygls.readthedocs.io/en/latest/howto/migrate-to-v2.html#renamed-languageserver-methods

@Snoopy1866
Copy link
Author

I see the LanguageServer class has been moved to the pygls.lsp module, may be that's the point of crushing.

https://pygls.readthedocs.io/en/latest/howto/migrate-to-v2.html#renamed-languageserver-methods

After some trying, i give it up, maybe that's beyond my ability. 🤣

@karthiknadig
Copy link
Member

@Snoopy1866 pygls v2 is still in alpha. I will migrate it when it becomes stable. Typically, core protocol packages should be pinned to a specific version. I actually own the underlying lsprotocol package that pygls consumes.

@karthiknadig karthiknadig added debt Technical debt or repo cleanup needs PR upstream Issue is in a dependency and removed triage-needed Issue is not triaged. labels Oct 14, 2024
@alcarney
Copy link

alcarney commented Nov 7, 2024

@karthiknadig ended up stumbling across this... don't you think it's strange that Esbonio is breaking this extension? Since we both ship our own Python envs, and they are installed into separate directories, they should be separate right?

Just wondering if I'm doing something wrong I guess! 😅

@karthiknadig
Copy link
Member

This can happen when, the mode is set to prioritize packages installed in the environment. Here, lsp server implementation is pulling pygls from the environment instead of the bundle. This should not happen, if the import strategy is set to useBundled where it will always pick the ones in the bundle first.

I am planning on changing this in a way where will pre-load the packages that are needed for the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Technical debt or repo cleanup needs PR upstream Issue is in a dependency
Projects
None yet
Development

No branches or pull requests

3 participants