Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command "rust-analyzer" is not present on the path. #3683

Closed
2 of 3 tasks
andrewbanchich opened this issue Aug 18, 2022 · 4 comments
Closed
2 of 3 tasks

Command "rust-analyzer" is not present on the path. #3683

andrewbanchich opened this issue Aug 18, 2022 · 4 comments
Labels

Comments

@andrewbanchich
Copy link

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

When opening a Rust project, I get an error saying it can't find a language server for Rust and offering to install rust-analyzer automatically.

*lsp-log* contains:

Command "rls" is not present on the path.
Command "rust-analyzer" is not present on the path.

rust-analyzer is already installed and works in my terminal.

I've read the troubleshooting link about this regarding setting PATH, but what confuses me is that everything was working for a while, but suddenly stopped working (I didn't make any changes to my config). I think a package update might have broken something, so I figured I'd post here with some more info.

I have been using nushell (not POSIX compliant) as my default shell for several weeks without any issues on macOS. I then took some time off and switched to my Linux laptop, set up nushell as default there, and then ran into this lsp-mode error. Because of that, I thought maybe it had something to do with my Linux machine or with how I configured nushell. However, today I switched back to my Mac, opened Emacs, packages auto updated, and ran into the same error after opening a Rust project. That's why I think it might be an update that broke something.

Steps to reproduce

I'm not sure since I don't know for sure what's causing it. I would assume setting nushell as default and using the latest version of lsp-mode would reproduce the issue.

Expected behavior

lsp-mode finds existing language servers.

Which Language Server did you use?

rust-analyzer

OS

MacOS

Error callstack

No response

Anything else?

No response

@yyoncho
Copy link
Member

yyoncho commented Aug 18, 2022

Use something like: (add-to-list 'exec-path (expand-file-name "~/go/bin")) or https://github.com/purcell/exec-path-from-shell (not sure if it supports your shell). But in any case, lsp-mode won't find the binary if it is not on the path and if emacs is not started from the shell it will have different path. FTR you can let lsp-mode install the server with M-x lsp-install-server

@yyoncho yyoncho closed this as completed Aug 18, 2022
@andrewbanchich
Copy link
Author

@yyoncho I tried that and it isn't working for me.

Originally I used this (from the Emacs Wiki):

(setenv "PATH" (concat (getenv "PATH") "..."))
(setq exec-path (append exec-path '("...")))

I also tried your suggestion:

(setenv "PATH" (concat (getenv "PATH") "..."))
(add-to-list 'exec-path (expand-file-name "..."))

where ... is what echo $PATH outputs from ZSH.

Looking at the output of getenv for PATH, it looks correct, and includes the path to rust-analyzer.

Does lsp-mode require the shell to be POSIX compliant? I suspect this could be related to me setting my default shell as nushell (which is not POSIX compliant), which seems to have broken exec-path-from-shell as well. However, I would have thought lsp-mode wouldn't be doing anything shell-specific.

@yyoncho
Copy link
Member

yyoncho commented Sep 17, 2022

@andrewbanchich we are using executable-find to check if a particular binary is available. I am not quite sure about the underlying implementation though.

(add-to-list 'exec-path (expand-file-name "..."))

This one should add the directory containing rust analyzer, not the path to the binary.

@andrewbanchich
Copy link
Author

Ah, I see. That's working now! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants