rksm / emacs-rust-config

emacs.d files for making Emacs a Rust development environment
MIT License
93 stars 29 forks source link

lsp cant start #2

Closed matianhe3 closed 3 years ago

matianhe3 commented 3 years ago

image

config:

(use-package rustic
  :config
  (setq rustic-format-on-save t))

(use-package lsp-mode
  :commands lsp
  :custom
  (lsp-auto-guess-root t)
  (lsp-keymap-prefix "M-m l")
  (lsp-modeline-diagnostics-enable nil)
  (lsp-keep-workspace-alive nil)
  (lsp-auto-execute-action nil)
  (lsp-before-save-edits nil)
  (lsp-eldoc-enable-hover nil)
  (lsp-diagnostic-package :none)
  (lsp-completion-provider :none)
  (lsp-file-watch-threshold 1500)
  (lsp-enable-links)
  :custom-face
  (lsp-face-highlight-read ((t (:underline t :background nil :foreground nil))))
  (lsp-face-highlight-write ((t (:underline t :background nil :foreground nil))))
  (lsp-face-highlight-textual ((t (:underline t :background nil :foreground nil))))
  :hook
  (lsp-mode . lsp-enable-which-key-integration))

In Message:

Loading /var/folders/3r/xrf9bp8x55x7bm5wmvs27gk80000gn/T/emacs-custom-501.el (source)...done
[yas] Prepared just-in-time loading of snippets (but no snippets found).
Loading /Users/matianhe/.cache/emacs/var/recentf-save.el (source)...done
Cleaning up the recentf list...done (0 removed)
For information about GNU Emacs and the GNU system, type C-h C-a.
*** Emacs loaded in 2.82 seconds with 5 garbage collections.
Switched to server rls.
Error in rustic-flycheck-setup: (user-error "/Users/matianhe/.config/cargo/bin/cargo metadata --no-deps --manifest-path /Users/matianhe/rust/Cargo.toml --format-version 1 exited with 1.")
LSP :: Connected to [rls:76177/starting].
Error in rustic-flycheck-setup: (user-error "/Users/matianhe/.config/cargo/bin/cargo metadata --no-deps --manifest-path /Users/matianhe/rust/Cargo.toml --format-version 1 exited with 1.")
LSP :: rls has exited (exited abnormally with code 1)
Updating buffer list...

IN lsp-log:

Command "rls" is present on the path.
Command "/Users/matianhe/.config/cargo/bin/rust-analyzer" is present on the path.
Command "rls" is present on the path.
Command "/Users/matianhe/.config/cargo/bin/rust-analyzer" is present on the path.
Found the following clients for /Users/matianhe/rust/src/main.rs: (server-id rls, priority -1), (server-id rust-analyzer, priority 1)
The following clients were selected based on priority: (server-id rust-analyzer, priority 1)

IN rust-analyzer::stderr:

[ERROR rust_analyzer::reload] failed to load workspace: "cargo" "--version" failed, exit code: 1
stderr:
error: no override and no default toolchain set
cargo check
    Checking rust v0.1.0 (/Users/matianhe/rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.75s
cargo --version
    cargo 1.51.0 (43b129a20 2021-03-16)
rksm commented 3 years ago

You'll probably need to make your environment variables visible to Emacs. The example setup uses the https://github.com/purcell/exec-path-from-shell package for that, see https://github.com/rksm/emacs-rust-config/blob/master/init.el#L126.

matianhe3 commented 3 years ago

You'll probably need to make your environment variables visible to Emacs. The example setup uses the https://github.com/purcell/exec-path-from-shell package for that, see https://github.com/rksm/emacs-rust-config/blob/master/init.el#L126.

i already installed. and other bash can execute.

rksm commented 3 years ago

Is emacs able to resolve the paths when you eval (Alt-:) the following expressions?

(executable-find "cargo")
(executable-find "rustc")
(executable-find "rust-analyzer")
rksm commented 3 years ago

Looking at your error messages, it seems that is not the issue. But

[ERROR rust_analyzer::reload] failed to load workspace: "cargo" "--version" failed, exit code: 1
stderr:
error: no override and no default toolchain set

looks like you need to set a default rust toolchain, e.g.

$ rustup default stable
matianhe3 commented 3 years ago

Looking at your error messages, it seems that is not the issue. But

[ERROR rust_analyzer::reload] failed to load workspace: "cargo" "--version" failed, exit code: 1
stderr:
error: no override and no default toolchain set

looks like you need to set a default rust toolchain, e.g.

$ rustup default stable
execute find:

"/Users/matianhe/.config/cargo/bin/cargo"
user-error: Minibuffer window is not active
"/Users/matianhe/.config/cargo/bin/rustc"
"/Users/matianhe/.config/cargo/bin/rust-analyzer"
~/m/work ❯❯❯ rustup default stable
info: using existing install for 'stable-x86_64-apple-darwin'
info: default toolchain set to 'stable-x86_64-apple-darwin'

  stable-x86_64-apple-darwin unchanged - rustc 1.51.0 (2fd73fabe 2021-03-23)

thanks, but it not work.

matianhe3 commented 3 years ago

i sovle it. i reinstall rust . and set defaut ENV ~/.rustup ~/.cargo . it run well. i change ENV to ~/.config/rustup ~/.config/cargo. it broken.