gentoo-rust icon indicating copy to clipboard operation
gentoo-rust copied to clipboard

Incorrect output on `rustc --print sysroot`

Open leonardohn opened this issue 5 years ago • 4 comments

I've been investigating the reasons for issue #498 and it turns out that rustc --print sysroot is not displaying the correct path and instead shows /usr. I don't remember exactly when it started but rust-analyzer and rls stopped working because of it, as they need to look for the component rust-src which goes inside the sysroot.

leonardohn avatar Sep 08 '20 18:09 leonardohn

As I remember /usr is correct sysroot value. What is expected value for rust-analyzer and rls?

o01eg avatar Sep 08 '20 18:09 o01eg

Both look for the sources at $(rustc --print sysroot)/lib/rustlib/src/rust/src by default. However, they work fine if I set the env RUST_SRC_PATH=/usr/lib64/rust-1.46.0/rustlib/src/rust. So, perhaps sysroot is pointing to the right place and rustlib should be inside /usr/lib?

leonardohn avatar Sep 08 '20 18:09 leonardohn

I suppose it should use something like $(rustc --print target-libdir)/../../src/rust/src

o01eg avatar Sep 08 '20 18:09 o01eg

It seems to be the default path both for racer (which rls depends on) and rust-analyzer.

https://github.com/racer-rust/racer/blob/bc478759f9f7f6dacd9ec26e7905dc8724740797/src/racer/util.rs#L504 https://github.com/rust-analyzer/rust-analyzer/blob/3f721683deb81c015484abd14eb67b96f39b1aff/crates/project_model/src/sysroot.rs#L134

Note: Both sources indicates that this path is going to change at version 1.47.0, according to https://github.com/rust-lang/rust/pull/73265.

leonardohn avatar Sep 08 '20 20:09 leonardohn