`rust-analyzer` returns `File not found` while cargo compiles
Problem
When I open an editor with rust-analyzer enabled and I try to include an asset, I get a file not found error message in the LSP.
At the same time, the project compiles fine
Steps To Reproduce
Steps to reproduce the behavior:
- create a new empty project with this content:
use manganis::*;
static _: &str = mg!(file("Cargo.toml"));
pub fn main(){}
- compile the project wtih
cargo check - open the file with an editor that uses
rust-analyzer
You get this error:
Diagnostics:
Failed to add asset: No such file or directory (os error 2)
Expected behavior
This code should not raise an error in the LSP
If applicable, add screenshots to help explain your problem.
Environment:
- Manganis version: 0.2.2
- Rust version: 0.1.75
- OS info: fedora
I know exactly where the error comes from.
When I replace this line: https://github.com/DioxusLabs/collect-assets/blob/c585779eaf615900f1a76f332905988da3922573/common/src/package.rs#L13
By:
std::fs::remove_dir_all(dir).unwrap();
I get this new error:
That means that there is a concurrency error, because:
// the directory exists at this moment
if dir.exists() {
tracing::info!("Clearing assets in {:?}", dir);
// but not at this moment
std::fs::remove_dir_all(dir).unwrap();
}
This was fixed in https://github.com/DioxusLabs/collect-assets/pull/30