Debug log (1)

Posted on Jul 19, 2024

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:

  1. I was trying to get virtualenvs, eglot, and various lsp servers to work.
  2. Things seemed to work basically just fine with pyright.
  3. 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:

  1. There are two language servers named python-language-server and python-lsp-server… the former downloads an executable called pyls while the latter downloads one named pylsp. 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..
  2. 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 and pyslp, called jedi, was installed to satisfy the constraints of pyls: specifically, it installed version 0.17.2 which is more than 2 or 3 years old. Installing pylsp later does not upgrade jedi.
  3. 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.