Open ambihelical opened 2 years ago
I think you have to move (rustic-lsp-client 'eglot)
to the :init
section. Why do you still use rls ? Just curious.
Or maybe :config
is enough, just give it a try.
rustic-lsp-client
and rustic-lsp-server
are custom variables so I used :custom as per best practice as I understand it. I moved them to init and then config with no change.
I'm using rls as I have been using rust infrequently, and it was working just fine. Do you think ra will make any difference here?
Do I need to load lsp-mode as well? I didn't think I needed it since I'm using eglot.
Something I left out of my report is that I used toggle-debug-on-error to get the backtrace. Normally only this message is in *Messages*
:
File mode specification error: (file-missing Cannot open load file No such file or directory lsp-mode)
As a by product of rustic not loading, my rust files are loaded in Fundamental mode.
I upgraded to rust-analyzer. I can get a little further with two changes to the rustic sources:
(use-package rust-mode)
However, there is still the JSON error. Below is the backtrace for it when I run toggle-debug-on-error. Also in case it matters, I am using the following rustc and cargo versions:
┏━ work@hum ~
┗━▶ cargo --version
cargo 1.58.0 (f01b232bc 2022-01-19)
┏━ work@hum ~
┗━▶ rustc --version
rustc 1.58.1 (db9d1b20b 2022-01-20)
Debugger entered--Lisp error: (json-readtable-error 119)
(signal json-readtable-error (119))
(json-read)
(let* ((output (json-read)) (dir (file-name-directory (cdr (assoc-string "root" output))))) (setq rustic--buffer-workspace dir))
(let ((ret (call-process (rustic-cargo-bin) nil t nil "locate-project" "--workspace"))) (if (and (/= ret 0) (not nodefault)) (progn (error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))) (goto-char 0) (let* ((output (json-read)) (dir (file-name-directory (cdr (assoc-string "root" output))))) (setq rustic--buffer-workspace dir)))
(progn (let ((ret (call-process (rustic-cargo-bin) nil t nil "locate-project" "--workspace"))) (if (and (/= ret 0) (not nodefault)) (progn (error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))) (goto-char 0) (let* ((output (json-read)) (dir (file-name-directory (cdr (assoc-string "root" output))))) (setq rustic--buffer-workspace dir))))
(unwind-protect (progn (let ((ret (call-process (rustic-cargo-bin) nil t nil "locate-project" "--workspace"))) (if (and (/= ret 0) (not nodefault)) (progn (error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))) (goto-char 0) (let* ((output (json-read)) (dir (file-name-directory (cdr ...)))) (setq rustic--buffer-workspace dir)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((ret (call-process (rustic-cargo-bin) nil t nil "locate-project" "--workspace"))) (if (and (/= ret 0) (not nodefault)) (progn (error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))) (goto-char 0) (let* ((output (json-read)) (dir (file-name-directory ...))) (setq rustic--buffer-workspace dir)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
(let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((ret (call-process ... nil t nil "locate-project" "--workspace"))) (if (and (/= ret 0) (not nodefault)) (progn (error "`cargo locate-project' returned %s status: %s" ret ...))) (goto-char 0) (let* ((output ...) (dir ...)) (setq rustic--buffer-workspace dir)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
(if rustic--buffer-workspace rustic--buffer-workspace (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((ret ...)) (if (and ... ...) (progn ...)) (goto-char 0) (let* (... ...) (setq rustic--buffer-workspace dir)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))
(rustic-buffer-workspace)
(rustic-compilation ("cargo" "build") (:clippy-fix t))
(rustic-compilation-start ("cargo" "build") (:clippy-fix t))
(rustic-run-cargo-command ("cargo" "build") (:clippy-fix t))
(rustic-cargo-build)
(funcall-interactively rustic-cargo-build)
(call-interactively rustic-cargo-build nil nil)
(command-execute rustic-cargo-build)
Do you think ra will make any difference here?
No it's just better.
Do I need to load lsp-mode as well? I didn't think I needed it since I'm using eglot.
You can also use eglot.
Change the required rust-mode version to 1.0.4 (or load it explicity using (use-package rust-mode)
That's not necessary.
Can you do me a favor and try something else just to be sure the reason isn't something else than rustic:
(use-package eglot)
(use-package rustic)
(setq rustic-lsp-client 'eglot)
If this is not working for you I have to think about it. However I'll try to get your config working.
I commented out my eglot and rustic sections and tried the config you gave me (keeping the commented out rustic-doc require). There is still the JSON error on build and others.
I did try a non-workspace project since this project is set up as workspace, and for that former project the build command works properly. So it seems to be a workspace issue, or maybe something with this project's config. I will try some other experiments since the non-ws project I used is basically hello-world, and not really doing anything.
Also If I remove my rust-mode package from the emacs.d/elpa directory and don't explicitly load rust-mode the following error occurs, so if rust-mode package isn't already present the incorrect version leads to this:
Unable to activate package ‘rustic’.
Required package ‘rust-mode-1.0.3’ is unavailable
Ok, I discovered the JSON issue. If I run this command as rustic seems to be doing:
cargo locate-project --workspace
I get the following output (replaced some paths with [removed]).
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package: [removed]/Cargo.toml
workspace: [removed]/Cargo.toml
{"root":"/[removed]/Cargo.toml"}
If I remove the problem causing the warning, OR use the --quiet flag, the output only has the json. So I guess rustic should be using the --quiet flag for robustness here.
wtf =)
Give me some time...
I'm using:
(use-package rustic
:mode ((rx ".rs" string-end) . rustic-mode)
:init
(setq rustic-lsp-client 'eglot)
:config
(require 'smartparens-rust))
I also had that setting in :config
originally, but pretty quickly saw why that would be wrong, so swapped it around - unfortunately the lsp-mode dependency seems to persist. Any idea why?
I recently updated rustic, only to find it no longer functions. Part of the issue seems to be that rustic-doc.el requires lsp-mode, which I'm not using as I'm using eglot. If I comment out the offending line, rustic loads, except that I now get an error:
json-read: JSON readtable error: 119
when I try to do anything likeC-c C-c C-b
, so this isn't the only issue.Another issue is that rustic requires rust-mode 1.03, but this isn't available. I added my own use-package load of rust-mode to get around this. It appears that 1.04 is the version it downloads.
Emacs version: 27.1
Rustic in my emacs.d/elpa directory:
rustic-20220220.1431/
My config:
The backtrace: