-
Notifications
You must be signed in to change notification settings - Fork 1.8k
"cargo metadata failed: No such file or directory (os error 2)" #3118
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
Comments
@samuela, thank you for the report! Can you please describe the directory structure of the project you open in VSCode that fails? |
It's https://github.com/samuela/rustybox. The Cargo.toml is in the root and then the entrypoint (rustybox.rs) is also in the root. I know that it's conventional to put things in |
May I ask you to dump |
Cloned the repo, installed the specified version of rust-analyzer, freshly installed the following
But couldn't reproduce the error... |
Here's the About info
FWIW there's also an info message "workspace loaded, 0 rust packages". |
Also getting this on 5e464d0. |
Here's what I'm seeing in the Output pane:
|
@samuela can you run |
It might make sense to retry after #3119 is merged: it should give a better error message. |
@marcogroppo Yes, I can export PATH="$HOME/.cargo/bin:$PATH" Not sure if it matters that I'm using zsh... |
Depending on how you set PATH, it might not be used by the extension. I was thinking of a common issue that occurs when starting Code from a DE, but the same thing might happen under Docker. The remote Code instance needs to be able to run cargo, but I'm not sure how to check for that. |
@lnicola Yeah I'm guessing it's a PATH issue. I'm starting VSCode on my laptop and then going through the whole "remote connect -> attach to running Docker container" song-and-dance. It prob doesn't help that the Docker container is on a remote machine, connected via SSH and {
"rust-analyzer.raLspServerPath": "/root/.cargo/bin/ra_lsp_server"
} even though |
@samuela ok, it's definitely a |
@marcogroppo I can try that. I wanted to avoid messing with |
@Veetaha Sure thing, I'm now seeing an error popup:
and the same info popup:
|
Here's the "Rust Analyzer Language Server" stuff in the Output panel:
|
@samuela May I ask you to try running the following command from
|
So this is interesting. When I run it in the VSCode Terminal pane I get a whole gob of json output as expected but when I SSH in and attach to the container I get
So for some reason the container's default shell is still bash even though VSCode Terminal opens up zsh. So then the question is which one is rust-analyzer using and why? Bash presumably? |
I tried adding |
|
If I run
it works, but perhaps that's because it's inheriting env vars for the parent bash session. |
I also tried putting |
@samuela I'm just guessing, but IMHO VSCode by default will try to run something as |
I think you can set environment variables in the Dockerfile? Our at least in devcontainer.json. |
I've just installed rust-analyzer from the VS Code marketplace, and I have the same problem:
and the output of the rust-analyzer is:
I just did |
Can you try running Code from a terminal? |
Is rustc in PATH for the proceeds which starts the server?
…On Wednesday, 4 March 2020, GuzTech ***@***.***> wrote:
I've just installed rust-analyzer from the VS Code marketplace, and I have
the same problem:
Version: 1.42.1
Commit: c47d83b293181d9be64f27ff093689e8e7aed054
Date: 2020-02-17T09:32:31.598Z
Electron: 6.1.9
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 5.5.7-zen1-1-zen
and the output of the rust-analyzer is:
[ERROR rust_analyzer::main_loop] loading workspace failed: Failed to read Cargo metadata from Cargo.toml file /home/oguz286/Projects/Rust/rcw/Cargo.toml
Caused by:
0: Failed to run `cargo metadata --manifest-path /home/oguz286/Projects/Rust/rcw/Cargo.toml`
1: No such file or directory (os error 2)
2: No such file or directory (os error 2)
[ERROR ra_project_model] failed to get rustc cfgs: Failed to get output from rustc --print cfg -O
I just did cargo new rcw so it's a clean project.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3118>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANB3M2JHMDGWMXWL5UDAULRF3I7RANCNFSM4KTVCK7A>
.
|
Yup
How do I check that?
|
Archlinux 5.5.13 Also got same error when trying to use emacs daemon. I added a PATH env var to my systemd service file to ensure it found cargo and seems to have fixed it for me. note - on exact same Rust project, I didn't get this error if I ran emacs alone (without the daemon). `[Unit] [Service] [Install] |
On Unix, we could sniff |
I am failing to find a solution in this thread, is there currently some clean workaround for this? I have installed the What should I do? Running Ubuntu 18.04. |
For me (on macOS) the workaround I've been using is to start VSCode via |
You can use |
Adding that line to the end of my Regardless, if someone wants to actually fix this in rust-analyzer, I'll remind people that @matklad (primary maintainer here IIUC) commented farther above in this thread that
I imagine this wouldn't be terribly difficult to make a PR for. Maybe I'll get around to making a PR for this soon. |
I have tried this and it did not work for me. Now it seems that the issue was that I had other VSCode windows open at the same time and that somehow interfered. I have closed all the windows and then the terminal approach works. Thanks! |
I think setting |
@Veetaha the problem is that |
Okay guys, let me tackle this |
Actually I'm already working on a fix |
Cool, thanks! |
@cdisselkoen |
I'm also not sure if https://github.com/rust-analyzer/rust-analyzer/blob/a4778ddb7a00f552a8e653bbf56ae9fd69cfe1d3/editors/code/src/cargo.ts#L79 in JS-land will need to be fixed as well. I'm not too familiar with VSCode extensions, or frankly, NodeJS at all. |
Let's not bother with this one, for now. You can ask for help in the PR regarding TypeScript part, I am sure I or any other person will respond |
^ the above commit partially fixes the problem, but I now get an error about finding |
Right, I think we can generalize this for a bit passing the env variable, executable name and standard location name so we can also cover |
it works. |
. if your in windows.. I recommend setting up your wsl subsystem... if your still using wsl subsystem but still does not work check if your have installed rust and cargo.. |
thank u so much dude |
I was facing the same issue, and this command worked for me. curl https://sh.rustup.rs -sSf | sh
export PATH="$HOME/.cargo/bin:$PATH |
I'm trying to work on a project that the RLS extension has no problem handling but I'm getting an odd error from rust-analyzer that is pretty unhelpful:
What file or directory could not be found? Why couldn't it be found even though RLS works without a hitch?
I'm running the VSCode extension remotely (Docker) with VSCode Insiders and rust-analyzer at commit 759100f.
The text was updated successfully, but these errors were encountered: