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

Language server crashes when using rtx 3.12 installation of python. #300

Open
taitep opened this issue Dec 18, 2023 · 5 comments
Open

Language server crashes when using rtx 3.12 installation of python. #300

taitep opened this issue Dec 18, 2023 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@taitep
Copy link

taitep commented Dec 18, 2023

I have recently switched from vscode to vscodium, and therefore also from pylance to jedi. On my laptop it works just fine, but on my desktop where i most often do things, and installed python through rtx, codium and jedi recently started having problems. I get this in the 'python language server' output of codium:

2023-12-18 10:51:05.040 [info]   Message: jedi.api.environment.InvalidPythonEnvironment: bin/python seems to be missing.
  Code: -32602 
{'traceback': ['  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/pygls/protocol.py", line 340, in _handle_request\n    self._execute_request(msg_id, handler, params)\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/pygls/protocol.py", line 264, in _execute_request\n    self._send_response(msg_id, handler(params))\n                                ^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi_language_server/server.py", line 380, in hover\n    jedi_script = jedi_utils.script(server.project, document)\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi_language_server/jedi_utils.py", line 118, in script\n    return Script(code=document.source, path=document.path, project=project)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi/api/__init__.py", line 119, in __init__\n    self._inference_state = InferenceState(\n                            ^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi/inference/__init__.py", line 87, in __init__\n    environment = project.get_environment()\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi/api/project.py", line 245, in get_environment\n    self._environment = create_environment(self._environment_path, safe=False)\n                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi/api/environment.py", line 367, in create_environment\n    return Environment(_get_executable_path(path, safe=safe), env_vars=env_vars)\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', '  File "/home/taitep/.vscode-oss/extensions/ms-python.python-2023.22.1/pythonFiles/lib/jedilsp/jedi/api/environment.py", line 380, in _get_executable_path\n    raise InvalidPythonEnvironment("%s seems to be missing." % python)\n']}

and after a reinstall codium does not even automatically find the installation, which it did before. The interpreter path is set to the python executable.

@taitep
Copy link
Author

taitep commented Dec 18, 2023

Also found this log in the 'python' output:

2023-12-18 11:00:26.077 [error] Active interpreter type is detected as Unknown {"id":"/home/taitep/.local/share/rtx/installs/python/3.12/bin/python","sysPrefix":"/home/taitep/.local/share/rtx/installs/python/3.12","envType":"Unknown","envName":"","envPath":"","path":"/home/taitep/.local/share/rtx/installs/python/3.12/bin/python","architecture":3,"sysVersion":"3.12.1 (main, Dec 18 2023, 09:14:00) [GCC 13.2.1 20230801]","version":{"raw":"3.12.1","major":3,"minor":12,"patch":1,"build":[],"prerelease":["final","0"]},"displayName":"Python 3.12.1 64-bit","detailedDisplayName":"Python 3.12.1 64-bit"}

@pappasam pappasam added the help wanted Extra attention is needed label Jan 19, 2024
@pappasam
Copy link
Owner

I don't use rtx, so any help from someone familiar with that ecosystem would be appreciated!

@bstaint
Copy link

bstaint commented Feb 1, 2024

Same。

environment_path=workspace_options.environment_path,

When workspace_options.environment_path is '' will raise InvalidPythonEnvironment, because:
https://github.com/davidhalter/jedi/blob/740b474eda983f5b44573d1748587709e3116815/jedi/api/project.py#L244

@s-light
Copy link

s-light commented Jul 1, 2024

seems i have a related issue here:

# .....
2024-07-01 12:34:24.579 [info] [Info  - 12:34:24 PM] Connection to server got closed. Server will restart.
2024-07-01 12:34:24.579 [info] true
2024-07-01 12:34:24.579 [info] [Error - 12:34:24 PM] Python Jedi client: couldn't create connection to server.
2024-07-01 12:34:24.579 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-07-01 12:34:24.579 [info] [Error - 12:34:24 PM] Restarting server failed
2024-07-01 12:34:24.579 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-07-01 12:34:25.244 [info] Traceback (most recent call last):
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/run-jedi-language-server.py", line 9, in <module>
    from jedi_language_server.cli import cli  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/jedi_language_server/cli.py", line 8, in <module>
    from .server import SERVER
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/jedi_language_server/server.py", line 68, in <module>
    from pygls.protocol import LanguageServerProtocol, lsp_method

2024-07-01 12:34:25.244 [info]   File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/pygls/protocol.py", line 43, in <module>
    from pygls.feature_manager import FeatureManager, assign_help_attrs, is_thread_function
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/pygls/feature_manager.py", line 28, in <module>
    from pygls.lsp import get_method_options_type, is_instance
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/pygls/lsp/__init__.py", line 36, in <module>
    from typeguard import check_type
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/typeguard/__init__.py", line 47, in <module>
    load_plugins()
  File "/home/stefan/.vscode-oss/extensions/ms-python.python-2024.8.1-universal/python_files/lib/jedilsp/typeguard/_checkers.py", line 770, in load_plugins

2024-07-01 12:34:25.244 [info]     for ep in entry_points(group="typeguard.checker_lookup"):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 913, in entry_points

2024-07-01 12:34:25.245 [info]     return EntryPoints(eps).select(**params)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 910, in <genexpr>

2024-07-01 12:34:25.245 [info]     eps = itertools.chain.from_iterable(
                                       ^
  File "/usr/lib/python3.12/importlib/metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 835, in _normalized_name

2024-07-01 12:34:25.245 [info]     or super()._normalized_name
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 462, in _normalized_name

2024-07-01 12:34:25.245 [info]     return Prepared.normalize(self.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 762, in normalize

2024-07-01 12:34:25.245 [info]     return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/re/__init__.py", line 186, in sub

2024-07-01 12:34:25.246 [info]     return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2024-07-01 12:34:25.246 [info] TypeError: expected string or bytes-like object, got 'NoneType'

2024-07-01 12:34:25.397 [info] [Error - 12:34:25 PM] Server process exited with code 1.
2024-07-01 12:34:25.398 [info] [Error - 12:34:25 PM] Server initialization failed.
2024-07-01 12:34:25.398 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 


2024-07-01 12:34:25.398 [info] [Error - 12:34:25 PM] The Python Jedi server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.


2024-07-01 12:34:25.398 [info] [Error - 12:34:25 PM] Python Jedi client: couldn't create connection to server.
2024-07-01 12:34:25.398 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 
2024-07-01 12:34:25.399 [info] [Error - 12:34:25 PM] Restarting server failed
2024-07-01 12:34:25.399 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 

my system

Codium:

Version: 1.89.1
Release: 24130
Commit: a045dcfceda27f896936bfd8cbf524f6a93a2f46
Date: 2024-05-09T18:30:40.866Z
Electron: 28.2.8
ElectronBuildId: undefined
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Linux x64 6.8.0-36-generic
python --version
Python 3.12.3
Operating System: Kubuntu 24.04
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13
Kernel Version: 6.8.0-36-generic (64-bit)
Graphics Platform: X11
Processors: 16 × Intel® Core™ i9-9980HK CPU @ 2.40GHz
Memory: 31,2 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ZenBook Pro Duo UX581GV_UX581GV
System Version: 1.0

i can follow @bstaint explanation.
but what is the fix for this? can i define the environment_path somehow?!
or is it a bug someone could fix with a pullrequest to the jedi project.py to include a check for an empty value?!

@s-light
Copy link

s-light commented Jul 1, 2024

seems this issue is related..
#266 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants