0

I'm trying (again![1][2]) to get lsp-jedi working on one of my systems (Gentoo Linux, same configuration works ok under Arch Linux).

I have pip install --user jedi-language-server so that it is available under the user account without activating a virtual environment.

❱ which python
/usr/bin/python
❱ which jedi-language-server
/home/user/.local/bin/jedi-language-server

I modify my exec-path very early on in my configuration.

;; Modify exec-path
(setq exec-path (append '("~/bin"
                          "~/.local/bin"
                          "~/.cargo/bin/"
                          "~/.node/bin/"
                          )
                        exec-path))

If I C-h v exec-path includes /home/user/.local/bin and M-: (executable-find "jedi-language-server") it too returns /home/user/.local/bin/jedi-language-server, so things look good so far.

I have the following lsp and lsp-jedi (as well as lsp-ui) configuration....

(use-package lsp-mode
  :ensure t
  :defer 1
  :init
  (setq lsp-keymap-prefix "C-c l")
  :config
  (setq lsp-idle-delay 0.5
    lsp-enable-symbol-highlighting t
    lsp-pylsp-plugins-pylint-args ["--rcfile=/home/neil/dotfiles/python/.pylintrc"])
  lsp-warn-no-matched-clients nil
  :hook ((lsp-mode . lsp-enable-which-key-integration)
     (R-mode . lsp)
     (bash-mode . lsp)
     (dockerfile-mode . lsp)
     (ess-r-mode . lsp)
     (gfm-mode . lsp)
     (groovy-mode . lsp)
     (html-mode . lsp)
     (julia-mode . lsp)
     (latex-mode . lsp)
     (markdown-mode . lsp)
     (org-mode . lsp)
     (python-mode . lsp)
     (sh-mode . lsp)
     (terraform-mode . lsp)))

(use-package lsp-ui
  :ensure t
  :hook (lsp-mode . lsp-ui-mode)
  :config
  (setq
   lsp-ui-doc-border (face-foreground 'default)
   lsp-ui-doc-delay 1
   lsp-ui-doc-enable t
   lsp-ui-doc-include-signature t
   lsp-ui-doc-header nil
   lsp-ui-doc-include-signature t
   lsp-ui-doc-position 'top
   lsp-ui-doc-show-with-cursor t
   lsp-ui-doc-show-with-mouse t
   lsp-ui-doc-use-childframe t
   lsp-ui-doc-use-childframe t
   lsp-ui-flycheck-enable t
   lsp-ui-flycheck-list-position 'right
   lsp-ui-flycheck-live-reporting t
   lsp-ui-imenu-enable t
   lsp-ui-peek-enable t
   lsp-ui-peek-list-width 60
   lsp-ui-peek-peek-height 25
   lsp-ui-sideline-delay 3
   lsp-ui-sideline-enable nil
   lsp-ui-sideline-enable t
   lsp-ui-sideline-ignore-duplicate t
   lsp-ui-sideline-show-code-actions t
   lsp-ui-sideline-show-hover t)
  :bind (:map lsp-ui-mode-map
          ("C-c i" . lsp-ui-imenu)))

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

But when I look at C-h v lsp-enabled-clients it is reported as nil which is confusing.

Ok lets do the sensible thing and strip things back...

So I started with a plain Emacs session (emacs -q) and then loaded the above configuration and whilst C-h v lsp-enabled-clients now lists jedi-language-server as the exec-path includes ~/.local/bin/ the jedi-language-server binary is not found and its not even in the registered list...

lsp-enabled-clients is a variable defined in ‘lsp-mode.el’.

Its value is (jedi-language-server)

List of clients allowed to be used for projects.
When nil, all registered clients are considered candidates.

If I open a *.py file which triggers python-mode this doesn't change things, its still trying to find the default set of clients rather than jedi-language-server.

LSP :: Client semgrep-ls is not in lsp-enabled-clients
LSP :: Client ruff-lsp is not in lsp-enabled-clients
LSP :: Client pyright is not in lsp-enabled-clients
LSP :: Client pylsp is not in lsp-enabled-clients
LSP :: Client pyls is not in lsp-enabled-clients
LSP :: Client jedi is not in lsp-enabled-clients
LSP :: Client semgrep-ls is not in lsp-enabled-clients
LSP :: Client ruff-lsp is not in lsp-enabled-clients
LSP :: Client pyright is not in lsp-enabled-clients
LSP :: Client pylsp is not in lsp-enabled-clients
LSP :: Client pyls is not in lsp-enabled-clients
LSP :: Client jedi is not in lsp-enabled-clients
LSP :: Client semgrep-ls is not in lsp-enabled-clients
LSP :: Client ruff-lsp is not in lsp-enabled-clients
LSP :: Client pyright is not in lsp-enabled-clients
LSP :: Client pylsp is not in lsp-enabled-clients
LSP :: Client pyls is not in lsp-enabled-clients
LSP :: Client jedi is not in lsp-enabled-clients
LSP :: There are no language servers supporting current mode `python-mode' registered with `lsp-mode'.
This issue might be caused by:
1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'.
2. The language server that you expect to run is not configured to run for major mode `python-mode'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'.
3. `lsp-mode' doesn't have any integration for the language behind `python-mode'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').
You can customize `lsp-warn-no-matched-clients' to disable this message.

The same happens if I activate a virtual environment first and I definitely have jedi-language-server installed in the virtual environment.

Completely baffled as the same configuration works fine on another system (albeit Arch rather than Gentoo but the system isn't the source of the problem here I don't think).

Any suggestions to try welcome and if I've omitted something please let me know.

Thanks,

slackline

[1]: LSP Jedi server error I've hit some trouble with lsp-mode and in particular lsp-jedi. I have my virtualenv selected under Emacs using pyvenv-workon and jedi-language-server is installed under the virtual environment. At the command line it starts without error. If I try opening a .py file in Emacs the ...

[2]: lsp-jedi debugging

EDIT : I think I may have made a mistake in my configuration as I've done some tinkering and after reading the FAQ : I have multiple language servers registered for language FOO. Which one will be used when opening a project? I checked *lsp-log* and it lists a found server (in a new virtual environment I had created) as jedi not jedi-language-server.

I've updated to

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

And still lsp-mode is not activated on opening a Python file which is recognised as such as has the major mode set to python-mode which sets jedi and disables pyls as language server which is great, but lsp-mode itself doesn't actually start, it errors with the following Backtrace which was too long to include in a post so its pastebinned.

1 Answer 1

0

Further tinkering and I think I've solved this, albeit by brute force and as usual the problem resided between the keyboard and the screen.

I had python-lsp-server and python-lsp-black installed globally under the system as well as having pip install --user pylsp.

After removing all of these lsp-mode can only find jedi/jedi-language-server that I have pip install --user jedi-language-server and also include as a default package to be installed whenever I create a new virtual environment.

As a consequence lsp-mode only find it as a possible client.

However, somewhat confusingly, if I start a new Emacs session and don't activate any virtual environment then I find that it uses an instance of jedi-language-server that is installed under a virtual environment...

Command "semgrep lsp" is not present on the path.
Command "ruff-lsp" is not present on the path.
Command "pylsp" is not present on the path.
Command "pyls" is not present on the path.
Command "jedi-language-server" is present on the path.
Command "semgrep lsp" is not present on the path.
Command "ruff-lsp" is not present on the path.
Command "pylsp" is not present on the path.
Command "pyls" is not present on the path.
Command "jedi-language-server" is present on the path.
Found the following clients for /mnt/work/git/lab/nshephard/mvdate/mvdate/mvdate.py: (server-id jedi, priority -1)
The following clients were selected based on priority: (server-id jedi, priority -1)

Even though when I M-: (executable-find "jedi-language-server") it returns ~/.local/bin/jedi-language-server which is the one installed with pip install --user jedi-language-server.

It's like the exec-path was completely ignored in favour of the priority settings which as far as I can tell can't be directly configured and its only via lsp-enabled-clients/lsp-disabled-clients that these can be configured (and even then they didn't seem to be recognised).

Somewhat confusing!

Further my python-mode-map bindings for doing tasks such as running pytest are no longer recognised!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.