Skip to content

Conversation

@cbarrete
Copy link
Contributor

@cbarrete cbarrete commented Dec 27, 2025

According to
https://rust-analyzer.github.io/book/non_cargo_based_projects.html, rust-analyzer should compute sysroot_src from sysroot if it is absent.

According to my testing, this is not the case, and rust-analyzer is broken if sysroot_src is not populated.

To fix this, we populate it from a new --sysroot-src flag, or the de facto standard RUST_SRC_PATH, which fixes the issue.

Ideally, rust-analyzer should be fixed but:

  1. I haven't gotten to the bottom of that bug.
  2. This commit remains correct in the meantime.
  3. This commit allows setups where the binary sysroot and source sysroots are different (as is the case in Nixpks, where they come from different packages).

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 27, 2025
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Dec 27, 2025

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D89837619. (Because this pull request was imported automatically, there will not be any future comments.)

According to
https://rust-analyzer.github.io/book/non_cargo_based_projects.html,
rust-analyzer should compute `sysroot_src` from `sysroot` if it is
absent.

According to my testing, this is not the case, and rust-analyzer is
broken if `sysroot_src` is not populated.

To fix this, we populate it from a new `--sysroot-src` flag, or the de facto standard
`RUST_SRC_PATH`, which fixes the issue.

Ideally, rust-analyzer should be fixed but:
1. I haven't gotten to the bottom of that bug.
2. This commit remains correct in the meantime.
3. This commit allows setups where the binary sysroot and source
   sysroots are different (as is the case in Nixpks, where they come
   from different packages).
@cbarrete cbarrete changed the title rust-project: populate sysroot_src from RUST_SRC_PATH rust-project: populate sysroot_src Jan 1, 2026
@cormacrelf
Copy link
Contributor

This is covered by #767 in a bit more of a comprehensive way. (767 auto populates sysroot_src from sysroot, and also checks that that sysroot_src path exists, i.e. whether you have the rust-src component if using rustup.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants