rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.12k stars 1.57k forks source link

VSCode rust-analyzer -- Looking for files from different projects in each other's folders - "File with cargo diagnostic not found in VFS: file not found:" #13520

Open jguhlin opened 1 year ago

jguhlin commented 1 year ago

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

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

rustc version: (eg. output of rustc -V) rustc 1.66.0-nightly (9565dfeb4 2022-10-28)

I am getting errors like these:

[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\src\masking\ml32bit.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\src\masking\ml32bit.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\src\masking\ml32bit.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\src\masking\ml32bit.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\src\datatypes\seq_loc.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\benches\ml32bit.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\libsfasta\benches\ml32bit.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\sfa\src\main.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\sfa\src\main.rs
[ERROR rust_analyzer::main_loop] flycheck 3: File with cargo diagnostic not found in VFS: file not found: c:\Development\phyloclap\sfa\src\main.rs

These are very weird, as those files should not exist (sfa and libsfasta are folders in a different project, and are not and should not be present in the phyloclap project).

It is referenced as such in Cargo.toml though: libsfasta = { path = "../sfasta/libsfasta" }

So maybe I am misunderstanding something? I have been trying to debug why I do not get compilation errors in VSCode anymore inline as red, but everything else re: Rust-analyzer is working, and this is the only type of error showing up.

EeroEternal commented 1 year ago

I had the same problem

duckfromdiscord commented 1 year ago

Still happening

duckfromdiscord commented 1 year ago

I don't think that's spam.

proc-moe commented 1 year ago

I met such problem using VSCode and rust-analyzer from the extensions of VSC marketplace.

file with cargo diagnostic not found in vfs: file not found: /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/string.rs

I solved it by following the instructions in the quickstart of rust-analyzer (v0.3.1566) and installed rustup 1.26.0-3 using pacman by $ pacman -S rustup (rustup and rust were in conflict in pacman so I removed rust 1.70.1)

then $ rustup default update installing stable-x86_64-unknown-linux-gnu installed - rustc 1.70.0 (90c541806 2023-05-31)

then I reinstalled the rust-analyzer extension and reload the rust-analyzer. It works well in my environment

Hope that can help you.

alibektas commented 1 year ago

It seems that this is related to how for some macros r-a cannot pinpoint the exact file, from which they are called. I will look into this once again in the near future. For future reference here is an instance where I encountered this error.

version : 94afbe33c 2023-09-09 rustc -v : rustc 1.72.0 (5680fa18f 2023-08-23)

What happened? Flycheck didn't work because of the said error.

What caused it? Enabling clippy with "rust-analyzer.check.extraArgs" : [ "--" , "-D" , "warnings" ]

I added an additional log to further investigate the causes

Additional line :

tracing::debug!("AddDiagnostic {} {:#?} {:#?}" , id , workspace_root , diagnostic );

Where it was added :

https://github.com/rust-lang/rust-analyzer/blob/cfcef69072aa87ecab6f127092972ccab201b7ee/crates/rust-analyzer/src/main_loop.rs#L612-L620

Related logs:

ERROR rust_analyzer::main_loop] flycheck 0: File with cargo diagnostic not found in VFS: file not found: /path/to/ra/rust-analyzer/src/lib.rs
[DEBUG rust_analyzer::main_loop] AddDiagnostic 0 AbsPathBuf(
    "/path/to/ra/rust-analyzer",
) Diagnostic {
    message: "approximate value of `f{32, 64}::consts::PI` found",
    code: Some(
        DiagnosticCode {
            code: "clippy::approx_constant",
            explanation: None,
        },
    ),
    level: Error,
    spans: [
        DiagnosticSpan {
            file_name: "src/lib.rs",
            byte_start: 1170,
            byte_end: 1174,
            line_start: 36,
            line_end: 36,
            column_start: 49,
            column_end: 53,
            is_primary: true,
            text: [
                DiagnosticSpanLine {
                    text: "        TokenTree::from(Literal::f64_unsuffixed(3.14)),",
                    highlight_start: 49,
                    highlight_end: 53,
                },
            ],
            label: None,
            suggested_replacement: None,
            suggestion_applicability: None,
            expansion: None,
        },
    ],
    children: [
        Diagnostic {
            message: "consider using the constant directly",
            code: None,
            level: Help,
            spans: [],
            children: [],
            rendered: None,
        },
        Diagnostic {
            message: "for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant",
            code: None,
            level: Help,
            spans: [],
            children: [],
            rendered: None,
        },
    ],
    rendered: Some(
        "error: approximate value of `f{32, 64}::consts::PI` found\n  --> src/lib.rs:36:49\n   |\n36 |         TokenTree::from(Literal::f64_unsuffixed(3.14)),\n   |                                                 ^^^^\n   |\n   = help: consider using the constant directly\n   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant\n\n",
    ),
}
alibektas commented 1 year ago

@rustbot claim

FryDarkLittleBeast commented 3 months ago

I met such problem using VSCode and rust-analyzer from the extensions of VSC marketplace.

file with cargo diagnostic not found in vfs: file not found: /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/string.rs

I solved it by following the instructions in the quickstart of rust-analyzer (v0.3.1566) and installed rustup 1.26.0-3 using pacman by $ pacman -S rustup (rustup and rust were in conflict in pacman so I removed rust 1.70.1)

then $ rustup default update installing stable-x86_64-unknown-linux-gnu installed - rustc 1.70.0 (90c541806 2023-05-31)

then I reinstalled the rust-analyzer extension and reload the rust-analyzer. It works well in my environment

Hope that can help you.

that does work. Tks~(though,currently the command seems to be