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

could not find Cargo.toml in /path/to/workspace or any parent directory - when Rust project is nested #13477

Closed
Dzejkop opened this issue Oct 24, 2022 · 5 comments · Fixed by #13478
Assignees

Comments

@Dzejkop
Copy link

Dzejkop commented Oct 24, 2022

Steps to reproduce

  1. Create an empty directory - dir1
  2. Within that directory create another directory dir2
  3. Withing dir2 initialize a rust project with cargo init
  4. Open the dir1 in VSCode
  5. Save the main.rs file
  6. The popup should appear

Description

Given a workspace structure

root_dir:
  project_dir:
    Cargo.toml
    src:
      main.rs

When saving a file I'm seeing an error popup with the content cargo check failed Check the server logs for additional info.

In the server logs I see this

[ERROR flycheck] Flycheck failed to run the following command: "cargo" "check" "--workspace" "--message-format=json" "--all-targets"
[ERROR rust_analyzer::lsp_utils] cargo check failed

Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(25856))):
error: could not find `Cargo.toml` in `/path/to/workspace` or any parent directory

rust-analyzer version: rust-analyzer version: 0.4.1257-standalone (43fb9563b 2022-10-23)

rustc version: rustc 1.64.0 (a55dd71d5 2022-09-19)

@Dzejkop
Copy link
Author

Dzejkop commented Oct 24, 2022

This appears to affect the pre-release version of rust-analyzer for VSCode, the release version is not affected

@Moskize91
Copy link

me too

@utkarshgupta137
Copy link

This is back today after upgrading to rust 1.66. I'm using Atom btw.

(base) [19:05] utkarsh:~ $ /Users/utkarsh/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rust-analyzer --version
rust-analyzer 1.66.0 (69f9c33d 2022-12-12)
(base) [19:05] utkarsh:~ $ rustc --version
rustc 1.66.0 (69f9c33d7 2022-12-12)

@utkarshgupta137
Copy link

This is back today after upgrading to rust 1.66. I'm using Atom on M1 Pro.

Default host: aarch64-apple-darwin
rustup home:  /Users/utkarsh/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin (default)
1.65-aarch64-apple-darwin

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
x86_64-unknown-linux-gnu
x86_64-unknown-linux-musl

active toolchain
----------------

stable-aarch64-apple-darwin (default)
rustc 1.66.0 (69f9c33d7 2022-12-12)

Reverting to the 1.65 toolchain fixed the issue for me.

@Veykril
Copy link
Member

Veykril commented Dec 16, 2022

Oh great, the latest stable shipped with the rust-analyzer that has this issue ... there isn't much we can do here since we can't patch the component, you'll have to redirect the server binary you are using to either an older rust toolchain or use a manually installedserver.

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