I am having a hell of a time trying to get lsp-mode
and pyright
to work on a remote server over tramp
and was hoping I could get some guidance. Here is what I have done:
On the host machine, I have the following line in ~/.config/doom/config.el
:
(setq tramp-default-method "ssh")
and which pyright
returns:
/home/user/anaconda3/bin/pyright
On the remote machine which pyright
returns:
/remotemachine/home/user/anaconda3/bin/pyright
Since doom emacs
is NOT installed on the remote machine, I opted to create an emacs configuration file on the remote machine /remotemachine/home/user/.emacs.el
with the following in it:
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'exec-path "/remotemachine/home/user/anaconda3/bin")
It is my understanding that 'tramp-own-remote-path
reads the PATH
information set in ~/.profile
, so I set the PATH
variable to include the paths for the pyright
executables in ~/.profile
:
export PATH="/remotemachine/home/user/anaconda3/bin:/remotemachine/home/user/anaconda3/sbin:$PATH"
On the host machine in doom emacs
, I open treemacs
which shows a project on a remote machine that I have been working on. I move the cursor down to that project name and hit enter. A little watch icon pops up and fairly quickly I can see the files in this project. I move the cursor down to a file called myfile.py
and hit enter. In the modeline I get the following:
LSP:: The following servers support current file but do not have automatic installation: semgrep-ls-tramp ruff-lsp-tramp pylsp-tramp pyright-remote pyright-tramp.
You may find the installation instructions at https://emacs-lsp.github.io/lsp-mode/page/languages.
(If you ahve already installed the server check *lsp-log*).
When I check the *lsp-log*
buffer, I see the following:
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.
After doing a little searching, I came across this reddit post: https://www.reddit.com/r/emacs/comments/qbrp0t/emacs_lsp_tramp/. Adapting some of the suggestions, I did the following:
On the host machine, I added the following to my config.el
file:
(lsp-register-client
(make-lsp-client :new-connection (lsp-tramp-connection "/ssh:user@remote-machine.com:/remotemachine/home/user/anaconda3/bin/pyright")
:major-modes '(python-mode)
:remote? t
:server-id 'pyright-remote))
I shutdown doom emacs
, ran doom sync
from the cli, and reopened doom emacs
, all on the host machine. Next, I repeated the above steps with treemacs
on the host machine. When I select myfile.py
, I get a new error:
Server pyright-remote:13693/starting exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n)
I select n
, and look at the *pyright-remote::stderr*
buffer and see the following:
/bin/sh: 1: /ssh:user@remote-machine.com:/remotemachine/home/user/anaconda3/bin/pyright: not found
I then check the *lsp-log*
buffer on the remote machine and see the following:
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 "/ssh:user@remote-machine.com:/remotemachine/home/user/anaconda3/bin/pyright" is present on the path.
Found the following clients for /ssh:user@remote-machine.com:/remotemachine/home/user/myproject/myfile.py: (server-id pyright-remote, priority 0)
The following clients were selected based on priority: (server-id pyright-remote, priority 0)
With the remote file (myfile.py
) open in doom emacs
, I run M-: (executable-find "pyright" t) RET
and get nil
. I quit doom emacs
. As a final effort, on the remote machine I updated ~/.emacs.el
to:
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
;;(add-to-list 'exec-path "/remotemachine/home/user/anaconda3/bin")
In /remotemachine/home/user/myproject
I added a .dir-locals.el
file with the following:
(add-to-list 'exec-path "/remotemachine/home/user/anaconda3/bin")
I launched doom emacs
, repeated the treemacs
steps above, and when I select myfile.py
I get:
Server pyright-remote:13693/starting exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n)
I select n
, check the *pyright-remote::stderr*
buffer:
/bin/sh: 1: /ssh:user@remote-machine.com:/remotemachine/home/user/anaconda3/bin/pyright: not found
and check the *lsp-log*
buffer:
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 "/ssh:user@remote-machine.com:/remotemachine/home/user/anaconda3/bin/pyright" is present on the path.
Found the following clients for /ssh:user@remote-machine.com:/remotemachine/home/user/myproject/myfile.py: (server-id pyright-remote, priority 0)
The following clients were selected based on priority: (server-id pyright-remote, priority 0)
Any ideas about what might be the problem? I’m very grateful for suggestions that anyone has to offer. Thank you!
doom info
of the host machine:
generated Dec 04, 2024 00:27:55
system Ubuntu 22.04.5 LTS Linux 5.15.167.4-microsoft-standard-WSL2 x86_64
emacs 29.4 EMACSDIR=~/.config/emacs/ EMACS=/usr/bin/emacs
doom 3.0.0-pre PROFILE=_@0 grafted, HEAD -> master, origin/master, origin/HEAD a24ff58 2024-06-26 23:21:06 -0400 ~/.config/doom/
shell /bin/bash
features ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2
M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
traits batch envvar-file custom-file
modules :config use-package :completion (company +childframe) (vertico +icons) :ui doom doom-dashboard hl-todo hydra modeline
nav-flash ophints (popup +defaults) tabs (treemacs +lsp) (vc-gutter +pretty) vi-tilde-fringe window-select workspaces :editor
(evil +everywhere) fold (format +onsave) multiple-cursors snippets word-wrap :emacs (dired +icons) electric (ibuffer +icons)
undo vc :term vterm :checkers (syntax +childframe) (spell +flyspell) :tools (debugger +lsp) ein (eval +overlay) lookup lsp
magit :os tty :lang data emacs-lisp (json +lsp +treesitter) (markdown +grip) org (python +lsp +pyright +conda) (rust +lsp) (sh
+lsp) (yaml +lsp) :config (default +bindings +smartparens)
packages (beacon) (dired-subtree) (doom-themes) (ein) (evil-tutor) (fireplace) (lsp-treemacs) (nerd-icons) (org-autolist) (poetry)
(python-black) (snow) (topsy) (treemacs-nerd-icons)
elpa cmake-mode