Skip to content

Doesn't work on Flatpak: "Rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file" #13926

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
DanielProg39 opened this issue Jan 10, 2023 · 9 comments
Labels
C-support Category: support questions

Comments

@DanielProg39
Copy link

Sorry, I know that similar issues were opened several times (#3118, #3885), but I have no idea about what causes my problem.
This is what notification from rust-analyzer looks like:

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/user/projects/fibonacci/Cargo.toml, Some(Version { major: 1, minor: 62, patch: 1 }): Failed to run "/home/user/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/user/projects/fibonacci/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)

This is just an example, for showcasing I made a repo for that project, you can have a look on Cargo.toml and any other files here.

@lnicola
Copy link
Member

lnicola commented Jan 10, 2023

error: could not execute process rustc -vV

Sounds like it couldn't run that. How did you install Rust, and do rustc -vV and cargo metadata work from the VS Code terminal (if you are using VS Code, that is)?

And please provide the information requested in the issue template:

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rustc version: (eg. output of rustc -V)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

@DanielProg39
Copy link
Author

rust-analyzer version: 0.3.1361-standalone
rustc version: 1.62.1 (e092d0b6b 2022-07-16)
relevant settings: idk, didn't change anything)

As far as I can remember, I installed Rust using a command provided on website, it just worked since then, I updated it couple times and didn't have any problems.
I use VSCodium, a libre fork of VS Code (binary provided by foss license) which doesn't change anything, I suppose.

do rustc -vV and cargo metadata work from the VS Code terminal

So here what I got:

rustc -vV

rustc 1.62.1 (e092d0b6b 2022-07-16)
binary: rustc
commit-hash: e092d0b6b43f2de967af0887873151bb1c0b18d3
commit-date: 2022-07-16
host: x86_64-unknown-linux-gnu
release: 1.62.1
LLVM version: 14.0.5

cargo metadata

warning: please specify --format-version flag explicitly to avoid compatibility problems
{"packages":[{"name":"fibonacci","version":"0.1.0","id":"fibonacci 0.1.0 (path+file:///home/user/projects/fibonacci)","license":null,"license_file":null,"description":null,"source":null,"dependencies":[],"targets":[{"kind":["bin"],"crate_types":["bin"],"name":"fibonacci","src_path":"/home/user/projects/fibonacci/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true}],"features":{},"manifest_path":"/home/user/projects/fibonacci/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":["fibonacci 0.1.0 (path+file:///home/user/projects/fibonacci)"],"resolve":{"nodes":[{"id":"fibonacci 0.1.0 (path+file:///home/user/projects/fibonacci)","dependencies":[],"deps":[],"features":[]}],"root":"fibonacci 0.1.0 (path+file:///home/user/projects/fibonacci)"},"target_directory":"/home/user/projects/fibonacci/target","version":1,"workspace_root":"/home/user/projects/fibonacci","metadata":null}

@lnicola
Copy link
Member

lnicola commented Jan 10, 2023

So here what I got:

Did you run those from a terminal, or from the Code terminal? Does anything change if you run Code from a terminal?

@DanielProg39
Copy link
Author

DanielProg39 commented Jan 10, 2023

Ah, do you mean that I have to launch Code from the terminal? Well I ran those using terminal inside Code.
I checked an output with one using Code terminal when Code launched from terminal and with one using my system terminal emulator. It is the same everywhere.

@lnicola
Copy link
Member

lnicola commented Jan 10, 2023

We just run cargo metadata with some arguments, if that can't find rustc, it's probably not our fault. Most users have problems because their PATH doesn't contain ~/.cargo/bin when they run Code from their DE, while running it from a terminal fixes this. Are you sure you don't have any weird environment variables set? You can try env | grep -P 'RUST|CARGO'.

@lnicola lnicola added the C-support Category: support questions label Jan 10, 2023
@DanielProg39
Copy link
Author

You can try env | grep -P 'RUST|CARGO'.

I tried, it returned nothing. I'm confused. I've compiled my programs many times succesfully and never had an issue.
It also could be that I use the Flatpak version of VSCodium and launch it in terminal with flatpak run com.vscodium.codium, so it, basically doesn't change anything. It also can be because maybe (I don't remember exactly) I had installed "Rust" add-on previously (I deleted it before installing rust-analyzer). What do you think?

@lnicola
Copy link
Member

lnicola commented Jan 10, 2023

I think we have an issue or two about the Flatpak version. That seems like it could cause problems.

@DanielProg39
Copy link
Author

Thanks, I will reinstall VSCodium asap and tell you about results

@DanielProg39
Copy link
Author

Installing VSCodium from .deb repo resolved the problem. Probably an issue is about something with Flatpak

@DanielProg39 DanielProg39 changed the title Yet another "Rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file" Doesn't wok on Flatpak: "Rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file" Jan 11, 2023
@DanielProg39 DanielProg39 changed the title Doesn't wok on Flatpak: "Rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file" Doesn't work on Flatpak: "Rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file" Jan 11, 2023
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

2 participants