Skip to content

rust-analyzer can't find sysroot for rustlings (only) #1981

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

Closed
crochethk opened this issue Jun 2, 2024 · 1 comment
Closed

rust-analyzer can't find sysroot for rustlings (only) #1981

crochethk opened this issue Jun 2, 2024 · 1 comment

Comments

@crochethk
Copy link

  • rustc --version:

    rustc 1.78.0 (9b00956e5 2024-04-29)
  • rustlings --version:

    rustlings 5.6.1
  • OS info:

    • Edition: Windows 10 Pro
    • Version:22H2
    • Build: 19045.4412

While using rust-analyzer with vscode and the rustlings project on a windows machine I get the following warning from rust-analyzer:

Failed spawning proc-macro server for workspace D:\my\path\to\rustlings\rust-project.json: no sysroot

I don't know if it matters, in terms of reproducing the issue, but I'm using a custom directory for rustlings and have it opened along with other rust-projects in the same vscode workspace.

I tried my best to look for a misconfiguration, reinstalled rustup and rustlings as per recommendation but it did not resolve it.

Finally I was able to fix it by adding the toolchain-path as sysroot property into the generated rust-project.json, as follows:

{
    "sysroot_src": "C:\\Users\\crochethk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\src\\rust\\library",
    "sysroot": "C:\\Users\\crochethk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc", // <----- manually added line
    "crates": [
        {
            "root_module": "exercises\\clippy\\clippy1.rs",
            "edition": "2021",
            "deps": [],
            "cfg": [
                "test"
            ]
        },
        //...
        {
            "root_module": "exercises\\vecs\\vecs2.rs",
            "edition": "2021",
            "deps": [],
            "cfg": [
                "test"
            ]
        }
    ]
}

So my suggestion is to include the sysroot in the generated rust-project.json file.

@mo8it
Copy link
Contributor

mo8it commented Jun 2, 2024

Sorry for the inconvenience. This should be solved in the upcoming version 6 since it uses Cargo instead of project.json.

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

No branches or pull requests

2 participants