I've encountered issues with lsp-jedi apparently sending a bad message to jedi-language-server which causes an Invalid Params error in Pythons pygls.

Having sought assistance from the author(s) of jedi-language-server[1] who suggested it might be an error in lsp-jedi[2] who suggested it was an error in the former I asked the authors of pygls[3] who suggested its a poorly formed command.

I'm stumped as to how to go about finding the call being made from Emacs though and would be grateful of advice.

I load lsp-jedi with...

(use-package lsp-jedi
  :ensure t
  (with-eval-after-load "lsp-mode"
    (add-to-list 'lsp-disabled-clients 'pyls)
    (add-to-list 'lsp-enabled-clients 'jedi)))

But none of the commands defined in lsp-jedi are then available such as lsp-jedi-debug and so adding (setq lsp-jedi-debug t) to the above :config didn't help.

I tried starting emacs --debug or emacs --debug-init and then opening a .py file but nothing pertaining to lsp-mode was shown in the *Backtrace* buffer.

Setting toggle-debug-on-error t didn't help since the error occurs external to Emacs after lsp-jedi has sent its commands to jedi-language-server.

The error that occurs is...

Server jedi:12920/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)

...and it never starts. In *jedi::stderr* the following error is shown...

Process jedi stderr finished
Traceback (most recent call last):
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 152, in deserialize_message
    deserialize_params(data, get_params_type)
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 138, in deserialize_params
    data['params'] = params_type(**params)
  File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for InitializeParams
  value is not a valid integer (type=type_error.integer)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/neil/.virtualenvs/default/bin/jedi-language-server", line 8, in <module>
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/jedi_language_server/cli.py", line 125, in cli
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/server.py", line 204, in start_io
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/server.py", line 75, in aio_readline
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 456, in data_received
  File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 154, in deserialize_message
    raise JsonRpcInvalidParams()
pygls.exceptions.JsonRpcInvalidParams: Invalid Params

*lsp-log* shows

Command "jedi-language-server" is present on the path.
Command "pyls" is not present on the path.
Command "pylsp" is not present on the path.
Command "jedi-language-server" is present on the path.
Command "pyls" is not present on the path.
Command "pylsp" is not present on the path.
Found the following clients for /home/neil/work/python/tcx2gpx/setup.py: (server-id jedi, priority -1)
The following clients were selected based on priority: (server-id jedi, priority -1)

The most frustrating thing is I use the same configuration home and work servers but this only occurs on my home server.

Any pointers on how to find out what lsp-jedi is requesting so I can investigate, as per the authors of pygls suggestion[3], whether its a malformed request or something on the server side would be very much appreciated.

  1. Language servers exits · Issue #208 · pappasam/jedi-language-server
  2. Starting jedi-language-server fails... · Issue #20 · fredcamps/lsp-jedi
  3. pydantic throws ValidationError · Issue #243 · openlawlibrary/pygls
  • Did you noticed on this page github.com/fredcamps/lsp-jedi the special configuration to work with virtual environments? is this enabled?
    – Ian
    Commented Jul 3, 2022 at 12:03
  • The module pylsp emacs-lsp.github.io/lsp-mode/page/lsp-pylsp/- shows already jedi module is enabled, and some other items related to working in virtual environments could be also enabled (currently disabled).
    – Ian
    Commented Jul 3, 2022 at 12:15
  • @Ian yes I'd seen those and had originally been using jedi-language-server after having activated venv under Emacs, but was advised that it should be system wide. I was keen to get jedi-language-server working rather than lsp-pylsp relying on jedi as it seemed a neater/cleaner solution, plus I read here about a Jedi version issue. Maybe I should revisit pyls, thanks for the pointers.
    – slackline
    Commented Jul 3, 2022 at 19:39


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.