rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.33k stars 1.61k forks source link

Can't load standard library using SSH #18550

Closed latot closed 1 hour ago

latot commented 3 hours ago

Hi, I was trying to use rust-analyzer from SSH, but seems to fail.

In the server side

mkdir a
cd a
cargo init

On client, connect using Remote-SSH to the a folder, wait to rust analyzer to finish, then here is the message:

2024-11-24T12:41:31.343562983-03:00 ERROR error="can't load standard library from sysroot\n{sysroot_path}\n(discovered via `rustc --print sysroot`)\ntry installing the Rust source the same way you installed rustc"
2024-11-24T12:41:31.83824882-03:00 ERROR error="can't load standard library from sysroot\n{sysroot_path}\n(discovered via `rustc --print sysroot`)\ntry installing the Rust source the same way you installed rustc"
2024-11-24T12:41:32.314165679-03:00 ERROR error="can't load standard library from sysroot\n{sysroot_path}\n(discovered via `rustc --print sysroot`)\ntry installing the Rust source the same way you installed rustc"

Rust-1.81..0 IDE: VSCode rust-analyzer: v0.3.2188 Linux: Gentoo 64 rustc --print sysroot: /opt/rust-bin-1.81.0 rustc -V: rustc 1.81.0 (eeb90cda1 2024-09-04)

lnicola commented 3 hours ago

What does ls $(rustc --print sysroot)/lib/rustlib/src/rust/library/ show?

latot commented 2 hours ago

mm, weird, does not exists, the upper path who exists is:

ls  $(rustc --print sysroot)/lib/rustlib/
components  etc  i686-unknown-linux-gnu  install.log  manifest-cargo  manifest-rustc  manifest-rust-std-x86_64-unknown-linux-gnu  rust-installer-version  uninstall.sh  x86_64-unknown-linux-gnu
latot commented 2 hours ago

@lnicola give me a moment, I did not enabled some options!

lnicola commented 2 hours ago

You need to install rust-src. Also, i686-unknown-linux-gnu?

latot commented 2 hours ago

now is working, would be nice be able to tell install the rust-src and probs rust-analyzer if they are not.

I'm also confuse about i686-unknown-linux-gnu, my system has x64_x86-pc-linux-gnu

lnicola commented 2 hours ago

We already try to run rustup component add rust-src, but if that doesn't work, it might be distro-specific. And we literally say it:

try installing the Rust source the same way you installed rustc

latot commented 2 hours ago

mmm, src is different from the normal dev files?

This is because, usually when you install with make install they comes with headers for example and some src files.

If we do that, we still will not get the Rust-src files, so seems it also need extra ones, maybe of the nomenclature I feel is little confusing.

Also, Rust-src seems to comes with a lot more than Rust sources, it comes tools to build other things.

Maybe instead of "Rust sources", just say "rust-src package" or something like that.

lnicola commented 2 hours ago

The standard library (e.g. core, std) are pre-compiled and you can always use them if they're available for your target. rust-src should contain the source code of the standard library. It's only useful for IDEs, or if you want to read it for some reason.

Also, Rust-src seems to comes with a lot more than Rust sources

It seems so. In Debian it includes the compiler source code and the books.