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

Rust analyzer fails to load workspace #12555

Closed
remaxsrb opened this issue Jun 16, 2022 · 17 comments
Closed

Rust analyzer fails to load workspace #12555

remaxsrb opened this issue Jun 16, 2022 · 17 comments
Labels
C-support Category: support questions

Comments

@remaxsrb
Copy link

I tried to find solutions on the stackoverflow and other similar issues in this list but none of the solutions seemed to work for me. I'm a rust noob and I've installed rust-analyzer in vscode. On mostly every "get started" video on youtube RA seems to work out of the books but I get this error message:

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/remax/Storage/Projects/rust/rusttest/Cargo.toml, cargo 1.61.0 (a028ae4 2022-04-29): Failed to run "/home/remax/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/remax/Storage/Projects/rust/rusttest/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu": cargo metadata exited with an error: error: could not execute process rustc -vV (never executed)
Caused by:
No such file or directory (os error 2)

In my workspace I only have a rust project folder created by running: cargo new projectname.

rustc --version outputs this rustc 1.61.0 (fe5b13d68 2022-05-18)
cargo --version outputs this cargo 1.61.0 (a028ae4 2022-04-29)

which rustc --> ~/.cargo/bin/rustc
which cargo --> ~/.cargo/bin/cargo

To be honest I'm getting really desperate here. Can't get this to work for a couple of days now.

Cargo.toml contains this:

[package]
name = "rusttest"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

I am well aware that this is one of the most common issues with beginners and that fixes are usually simple so don't hold it against me for repeating a question. Thanks in advance for your help.

@flodiebold
Copy link
Member

If you go to your project folder in the terminal and run /home/remax/.cargo/bin/cargo metadata --format-version 1 --manifest-path /home/remax/Storage/Projects/rust/rusttest/Cargo.toml --filter-platform x86_64-unknown-linux-gnu, what does it say? If that works, does it still work in the VSCode terminal tab?

@flodiebold flodiebold added the C-support Category: support questions label Jun 16, 2022
@remaxsrb
Copy link
Author

Both terminal and vscode terminal tab output the same thing:

{"packages":[{"name":"rusttest","version":"0.1.0","id":"rusttest 0.1.0 (path+file:///home/remax/Storage/Projects/rust/rusttest)","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["bin"],"crate_types":["bin"],"name":"rusttest","src_path":"/home/remax/Storage/Projects/rust/rusttest/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true}],"features":{},"manifest_path":"/home/remax/Storage/Projects/rust/rusttest/Cargo.toml","metadata":null,"publish":null,"authors":[],"categories":[],"keywords":[],"readme":null,"repository":null,"homepage":null,"documentation":null,"edition":"2021","links":null,"default_run":null,"rust_version":null}],"workspace_members":["rusttest 0.1.0 (path+file:///home/remax/Storage/Projects/rust/rusttest)"],"resolve":{"nodes":[{"id":"rusttest 0.1.0 (path+file:///home/remax/Storage/Projects/rust/rusttest)","dependencies":[],"deps":[],"features":[]}],"root":"rusttest 0.1.0 (path+file:///home/remax/Storage/Projects/rust/rusttest)"},"target_directory":"/home/remax/Storage/Projects/rust/rusttest/target","version":1,"workspace_root":"/home/remax/Storage/Projects/rust/rusttest","metadata":null}

@flodiebold
Copy link
Member

What does running ~/.vscode/extensions/rust-lang.rust-analyzer-*/server/rust-analyzer analysis-stats . in the project folder say?

@remaxsrb
Copy link
Author

It says:

bash: /home/remax/.vscode/extensions/rust-lang.rust-analyzer-*/server/rust-analyzer: No such file or directory

@flodiebold
Copy link
Member

Hrm. Does /home/remax/.vscode exist? Is there anything in /home/remax/.vscode/extensions?

@remaxsrb
Copy link
Author

remaxsrb commented Jun 16, 2022

So what you are saying is that it will work with vscode and not vscodium? I thought it wouldn't make any difference so I didn't mention that I installed Vscodium and not Vscode

@flodiebold
Copy link
Member

No, but if you're using VSCodium that would be pertinent information. How did you install rust-analyzer (the server binary, not the extension)? What version of the extension do you have installed?

@remaxsrb
Copy link
Author

rust-analyzer v0.2.853
I only installed the extension and that's it.

@flodiebold
Copy link
Member

That's a rather old version of the extension, because VSCodium doesn't support the platform-specific extensions we publish nowadays. I'm not sure what the best way to install a current version in VSCodium is right now; you might be able to download and install a vsix from the releases page here.

@remaxsrb
Copy link
Author

I guess I will just install vscode, it seems like the simplest solution. Thanks for your help and patience.

@flodiebold
Copy link
Member

You're welcome!

@lnicola
Copy link
Member

lnicola commented Jun 16, 2022

Yeah, installing the VSIX from the release page works. You can also do this, but it's probably against the license.

@toddewilliams
Copy link

Yeah, installing the VSIX from the release page works...

@lnicola You mean the latest version works in VSCodium? Because from what @flodiebold said, it shouldn't work due to the "platform-specific extensions" mentioned.

That's a rather old version of the extension, because VSCodium doesn't support the platform-specific extensions we publish nowadays.

@flodiebold do you have further clarity you can provide? Because if it does work in VSCodium then updating the existing open-vsx.org listing would be excellent.

@flodiebold
Copy link
Member

If @lnicola says it works, I would assume it works. I'm probably not up to date on what's blocking the openvsx releases, it might just be the rust-lang move now.

@lnicola
Copy link
Member

lnicola commented Jun 28, 2022

You can download the VSIX from GitHub and install it, this always worked. What didn't was actually publishing it to open-vsx.org. They've recently added support for the stuff we need, but we've been waiting to get access to the rust-lang namespace there. This is done and someone from the infra team is now looking into getting an access token and adding it to our CI.

When that happens, we'll try to publish a version there. If nothing goes wrong (*), there will be a pre-release version this week and a stable one on Monday.

(*): we've seen the official (Microsoft) marketplace fail in some spectacular ways, OpenVSX may or may not be working.

EDIT: access token is now set up.

@toddewilliams
Copy link

toddewilliams commented Jun 28, 2022

That's excellent news and thank you for the clarification. Best of luck getting it all sorted out as we've also had some issues from time to time uploading to both marketplaces. But with some persistence, it always gets done.

@lnicola
Copy link
Member

lnicola commented Jun 29, 2022

@toddewilliams you might want to follow #11080.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions
Projects
None yet
Development

No branches or pull requests

4 participants