linuxwindowspathrust-analyzer

Rust Analyzer Error failed to load linked project: project root must point to Cargo.toml or rust-project.json (Root is in windows path format)


I previously was working on this project on windows, and then uploaded the files to git. I then cloned the project onto a Linux machine which is where I am now getting this error.

2024-04-14T00:09:38.204084Z ERROR rust_analyzer::config: failed to load linked project: project root must point to Cargo.toml or rust-project.json: /home/Me/Documents/code/rust/logger-util/.\logger-util\Cargo.toml

Due to the .\logger-util\Cargo.toml I am assuming the error is with the path being copied directly from windows? Despite Rust-Analyzer erroring, I can still use it to run the main function, and it the expected behavior (Logging something) is working.If I cd down into the project, the path looks as expected on linux, like this

**/**/**

Not the windows version of path using \

I'm not sure what could solve this, but any ideas and suggestions are welcomed


Solution

  • The issue was due to how I structured my project.

    enter image description here

    Due to creating a top folder first, and using cargo new inside of that, I had a nested project. The rust analyzer didn't like that, so I had to create a .vscode settings file to tell rust analyzer to point directly to the Cargo.toml. However, since I did this on windows, it copied the windows path format. When I cloned this onto my linux machine it couldn't understand, hence the error.

    For now, I just changed the folder on both machines, and removed the .vscode folder from the git repo, so the folder is only on local.

    I'm not sure how to create a universal path for both OS's, however when I do I'll edit this answer to explain.