1

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
  :config
  (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
processId
  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>
    sys.exit(cli())
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/jedi_language_server/cli.py", line 125, in cli
    SERVER.start_io()
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/server.py", line 204, in start_io
    self.loop.run_until_complete(
  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
    proxy(b''.join(message))
  File "/home/neil/.virtualenvs/default/lib/python3.9/site-packages/pygls/protocol.py", line 456, in data_received
    json.loads(body.decode(self.CHARSET),
  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
slackline
  • 293
  • 3
  • 14
  • Did you noticed on this page https://github.com/fredcamps/lsp-jedi the special configuration to work with virtual environments? is this enabled? – Ian Jul 03 '22 at 12:03
  • The module ```pylsp``` https://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 Jul 03 '22 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](https://www.mattduck.com/lsp-python-getting-started.html) about a Jedi version issue. Maybe I should revisit `pyls`, thanks for the pointers. – slackline Jul 03 '22 at 19:39

0 Answers0