Skip to content

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

Closed
@Dzejkop

Description

@Dzejkop

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions