Debug log (1)
So I spent some time cleaning up my python LSP setup with emacs today and, of course, it wasn’t simple – though for once this was not emacs’ fault.
Context:
- I was trying to get virtualenvs,
eglot
, and various lsp servers to work. - Things seemed to work basically just fine with
pyright
. - However things got weird when using
pylsp
. Specifically, things would work when I didn’t have venvs activated, but would break with venvs activated. I tried to uninstall and reinstall the language server in the venv but it didn’t work.
Ok, those were the observations. This should be enough clues for anyone experienced in python (or some other language) dependency hell.. but I guess that’s not my bread and butter so I struggled for a while. The problem was manifold:
- There are two language servers named
python-language-server
andpython-lsp-server
… the former downloads an executable calledpyls
while the latter downloads one namedpylsp
. The latter is a fork of the former.. and is the one I actually want. But I got confused in the naming so I kept updating the previous one.. - The larger issue though was that I had installed the former in the first place. This meant that
one of the dependencies common to
pyls
andpyslp
, calledjedi
, was installed to satisfy the constraints ofpyls
: specifically, it installed version0.17.2
which is more than 2 or 3 years old. Installingpylsp
later does not upgradejedi
. - I ended up updating jedi to the latest and.. it fixed my problem.
To narrow things down, I essentially installed a clean venv with only pylsp
and then just
compared the versions for all the packages installed, narrowing it down to Jedi.
I’m oviously tempted to blame everything (stupidly named packages, over-modularization), etc.. but I’m just sore because I know I should have been able to troubleshoot that faster. Lesson learned.