Skip to content

Failed to read Cargo metadata from Cargo.toml file #3885

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

Closed
travistrue2008 opened this issue Apr 8, 2020 · 6 comments
Closed

Failed to read Cargo metadata from Cargo.toml file #3885

travistrue2008 opened this issue Apr 8, 2020 · 6 comments

Comments

@travistrue2008
Copy link

travistrue2008 commented Apr 8, 2020

I'm working with rust-analyzer on Solus, and I keep getting this error whenever I open my workspace in VSCode:

Capture

The error kind of sounds like it either can't find the Cargo.toml file at that path, or it's missing manifest information? The Cargo.toml file is definitely at that path. Here's what it looks like:

[workspace]
members = [
	"game",
	"unpacker",
	"scraper_bestiary",
]

I'm not sure if it's an issue with my project or not because my Rust workspace project seemed to work fine with Rust Analyzer in my WSL installation. It seems like Rust Analyzer isn't running at all as a result of this.

I followed the installation instructions for the VSCode extension, and clicked the Download Now button when prompt. I also tried the suggestion in that error, and ran cargo metadata --manifest-path /home/travis/rust/rpg/Cargo.toml. I got a ton of output in my terminal, but it didn't appear that Rust Analyzer was running. It wouldn't get rid of that error whenever I closed and reopened VSCode either. Finally, I completely uninstalled Rust, and reinstalled it via rustup.

Is there anything that I could be overlooking?

@lnicola
Copy link
Member

lnicola commented Apr 8, 2020

I think cargo is not on your PATH, can you try running Code from the terminal?

There are a couple of older issues for the same error.

@travistrue2008
Copy link
Author

Yeah, I included cargo in my PATH, and cargo would be a recognized command in the VSCode's integrated terminal. When I echo $PATH, I get this for output:

/home/travis/.cargo/bin:/sbin:/bin:/usr/sbin:/usr/bin:/snap/bin

I did not try launching VSCode via terminal, yet though. I tried your suggestion of launching VSCode from the terminal, and that seemed to work. Not sure why that works, but Rust Analyzer is working now.

Thanks!

@lnicola
Copy link
Member

lnicola commented Apr 8, 2020

See #1811, #2496, #1533 or #3118. Code doesn't read your .profile file, but the integrated terminal does because it spawns a shell.

@lnicola lnicola closed this as completed Apr 8, 2020
@matklad
Copy link
Member

matklad commented Apr 9, 2020 via email

@luckynumberke7in
Copy link

I agree...It would be very nice to have a specific error message for this. I just set up a new system and must have done it wrong and ran into this issue...

A more precise error message would have saved me quite a bit of time / annoyance finding this.

@lnicola
Copy link
Member

lnicola commented Aug 25, 2024

I think "failed to run cargo metadata" is as precise as we can be. I think we now auto-detect rustup-installed toolchains, so if you hit this, you're using a distro toolchain (which should be in PATH anyway), Flatpak or some other weird setup that we can't even imagine.

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

No branches or pull requests

4 participants