-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Rust LSP (rust-analyzer) fails to start properly for any crate not in the ~
folder
#14894
Comments
This sounds like an issue with the LSP server, can you post the content of the lsp-log? I would like to know what the server complains about. |
It seems that the LSP server is starting up fine.
|
@Chronal |
Okay, there is some progress! I deleted the There are still some error messages however:
A very similar error message pops up when opening up each rust project. |
I've never seen this. Can you retry after updating rust analyzer and emacs packages, specifically flycheck and rust related ones? |
I updated all my packages:
I am still getting the error messages when opening a rust project, however:
The lsp server is being properly initializing the project folders and autocomplete is working in those projects despite the errors. |
Does |
Yes, it does.
|
Does the issue persist? |
I still get an error message, but the LSP initialises correctly in the right folder. Autocomplete and commands triggered using the leader key (",") seem to work as expected.
|
@Chronal If LSP doesn't start properly it may show DISCONNET in the modeline. You can also try "SPC m b" to see whether there are key bindings for LSP client related functions. If it's working there should be 4. What do you see? |
Yeah, it's a strange issue. The I don't see DISCONNECT in the modeline and
|
so aside from the error message, is everything appears okay? |
I think so, yeah. |
@Chronal |
This is my
|
Your As for the error (reformatted for readability): ;; Error in flycheck-rust-setup:
(wrong-type-argument
listp
#s(hash-table
size 65
test equal
rehash-size 1.5
rehash-threshold 0.8125
data ("packages" (#s(hash-table
size 65
test equal
rehash-size 1.5
rehash-threshold 0.8125
data ("name" "lispcalc"
"version" "0.1.0"
"id" "lispcalc 0.1.0 (path+file:///home/chronal/Projects/Programming/personal/simple-lisp)"
"license" nil
"license_file" nil
"description" nil
"source" nil
"dependencies" nil
"targets" (#s(hash-table
size 65
test equal
rehash-size 1.5
rehash-threshold 0.8125
data ("kind" ("lib")
"crate_types" ("lib")
"name" "compiler"
"src_path" "/home/chronal/Projects/Programming/personal/simple-lisp/src/lib.rs"
"edition" "2018"
"doc" t
"doctest" t
"test" t))
#s(hash-table
size 65
test equal
rehash-size 1.5
rehash-threshold 0.8125
data ("kind" ("bin")
"crate_types" ("bin")
"name" "repl"
"src_path" "/home/chronal/Projects/Programming/personal/simple-lisp/src/main.rs"
"edition" "2018"
"doc" t
"doctest" :json-false
"test" t)))
"features" #s(hash-table
size 65
test equal
rehash-size 1.5
rehash-threshold 0.8125
data ())
"manifest_path" "/home/chronal/Projects/Programming/personal/simple-lisp/Cargo.toml"
"metadata" nil
"publish" nil
"authors" ("Anuj Dhavalikar <chronal@chronal.space>")
"categories" nil
"keywords" nil
"readme" "README.md"
"repository" nil
"homepage" nil
"documentation" nil
"edition" "2018"
"links" nil
"default_run" nil)))
"workspace_members" ("lispcalc 0.1.0 (path+file:///home/chronal/Projects/Programming/personal/simple-lisp)")
"resolve" nil
"target_directory" "/home/chronal/Projects/Programming/personal/simple-lisp/target"
"version" 1
"workspace_root" "/home/chronal/Projects/Programming/personal/simple-lisp"
"metadata" nil))) this error is straightforward, it expects a list, but gets a hash table. the hash table itself looks valid, and you can see it's basically what you get with |
just to verify your flycheck-rust is up to data. |
Also, please enable debug, retry, and paste the error. |
I'm sorry for the delayed response. The VERSION is 20190319.1546, so flycheck-rust is up to date. When opening a rust file with after running
This is the error as displayed in messages
|
@Chronal for reference, I manually evaluated the last two calls before the error:
Can you do the same (git clone the repo to /tmp and manually run those functions) and paste the output? |
fwiw i am running into the same error running cargo 1.54.0 (5ae8d74b3 2021-06-22) and rustc 1.54.0 (a178d0322 2021-07-26). i started a brand new project with also, i checked my version of |
This is the output of those
When trying to open
|
@Chronal The following is the part of backtrace relevant here: Debugger entered--Lisp error: (wrong-type-argument listp #<hash-table equal 7/65 0x158afa5bf049>)
flycheck-rust-get-cargo-targets("/home/chronal/Projects/simple-lisp/Cargo.toml")
flycheck-rust-find-cargo-target("/home/chronal/Projects/simple-lisp/src/lib.rs")
flycheck-rust-setup() When a Rust buffer is opened, It calls During But What's the output of (let-alist
(with-temp-buffer
(call-process cargo nil '(t nil) nil
"metadata" "--no-deps"
"--manifest-path" "/tmp/simple-lisp-interpreter/Cargo.toml"
"--format-version" "1")
(goto-char (point-min))
(let ((json-array-type 'list))
(json-read)))
.packages) it should be (((name . "lispcalc")
(version . "0.1.0")
(id . "lispcalc 0.1.0 (path+file:///tmp/simple-lisp-interpreter)")
(license)
(license_file)
(description)
(source)
(dependencies)
(targets
((kind "lib")
(crate_types "lib")
(name . "compiler")
(src_path . "/tmp/simple-lisp-interpreter/src/lib.rs")
(edition . "2018")
(doc . t)
(doctest . t)
(test . t))
((kind "bin")
(crate_types "bin")
(name . "repl")
(src_path . "/tmp/simple-lisp-interpreter/src/main.rs")
(edition . "2018")
(doc . t)
(doctest . :json-false)
(test . t)))
(features)
(manifest_path . "/tmp/simple-lisp-interpreter/Cargo.toml")
(metadata)
(publish)
(authors "Anuj Dhavalikar <chronal@chronal.space>")
(categories)
(keywords)
(readme . "README.md")
(repository)
(homepage)
(documentation)
(edition . "2018")
(links)
(default_run))) If this runs correctly without error, please evaluate (let ((cargo (funcall flycheck-executable-find "cargo")))
(let-alist
(with-temp-buffer
(call-process cargo nil '(t nil) nil
"metadata" "--no-deps"
"--manifest-path" "/tmp/simple-lisp-interpreter/Cargo.toml"
"--format-version" "1")
(goto-char (point-min))
(let ((json-array-type 'list))
(json-read)))
(seq-map (lambda (pkg) (let-alist pkg .targets)) .packages))) and the output should be ((((kind "lib")
(crate_types "lib")
(name . "compiler")
(src_path . "/tmp/simple-lisp-interpreter/src/lib.rs")
(edition . "2018")
(doc . t)
(doctest . t)
(test . t))
((kind "bin")
(crate_types "bin")
(name . "repl")
(src_path . "/tmp/simple-lisp-interpreter/src/main.rs")
(edition . "2018")
(doc . t)
(doctest . :json-false)
(test . t)))) |
This comment has been minimized.
This comment has been minimized.
Just as another data point: I get the same error message as the OP from a "Hello, world!"-like project, too. Regarding the output requested on 23 Sep above, I get:
and
|
Apologies again for the lack of timely communication on my part. I ran the first command, with a slight modification. Instead of Running the first command, I get the following
This matches the expected output almost exactly. The only difference I can see is The next command outputs this
which matches the expected output exactly. |
I spent some time today getting familiar with elisp so that I could try debug the issue. Here's what I've got so far. After the line 107 in flycheck-rust.el, I checked the value of (let ((json-array-type 'list))
(json-read))) to (let ((json-array-type 'list)
(json-object-type 'alist))
(json-read))) This fix works, but it it is odd that The above only takes care of the After restarting spacemacs and opening a
and this is the contents of the
Finally, I've noticed some issues with Cargo-Process. Running cargo build for example
Should I create a separate issue for this? |
Hello! I use Emacs and recently faced problem with
I just started configuring Emacs for Rust, don't know much about ecosystem for now.
Although "LSP :: Error from the Language Server: waiting for cargo metadata or cargo check (Unknown error)" persists. |
It looks like everything is working properly on cargo's side as we always see the same result from cargo's metadata. The only problem is the wrong type of argument error and I've no idea what caused it. The issue with control sequence is likely fixed in a recent commit. Please retry. |
I have the same issue with 'flycheck-rust-setup failing. |
thanks for reporting. |
I have retried after updating, however the control sequences issue persists. I have found a fix here: kwrooijen/cargo.el#45. By setting the I'm glad that fix seems to be working for others. Thanks for making a pull request to push it upstream. 😄 |
@Chronal |
Hey, I've run |
I think flycheck-rust is practically dead, hence why flycheck/flycheck-rust#82 is still not merged after almost a year. Is there a valid reason to be using flycheck-rust anyways now that flycheck supports Rust directly? |
Bump.
@lebensterben is there a way to use the standard flycheck? I've been recently having intermittent issues with the rust layer and before that the issues cited on this thread. |
I have used this and it works |
Description
Trying to use the rust
lsp-mode
withrust-analyzer
doesn't work.Reproduction guide 🪲
eshell
cd
a directory outside of~
, Eg:cd ~/Documents
cargo new test-crate
src/main.rs
file in thetest-crate
directoryflycheck-rust-setup
failed and the lsp isn't working properly inside the folderObserved behaviour: 👀 💔
LSP :: Error from the Language Server: waiting for cargo metadata or cargo check (Unknown error)
~
folder by default:LSP :: rust-analyzer:1150323 initialized successfully in folders: (/home/chronal)
Expected behaviour: ❤️ 😄
System Info 💻
Backtrace 🐾
The text was updated successfully, but these errors were encountered: