racer-rust / racer

Rust Code Completion utility
MIT License
3.36k stars 278 forks source link

"Unable to find libstd under RUST_SRC_PATH" #1137

Open kfrncs opened 3 years ago

kfrncs commented 3 years ago

When I run racer complete std::io::B, I get this:

Unable to find libstd under RUST_SRC_PATH. N.B. RUST_SRC_PATH variable needs to point to the *s│ rc* directory inside a rust checkout e.g. "/home/foouser/src/rust/src". Current value ""/home/ken/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd""

Despite the fact that my ~/.zshrc contains:

export RUST_SRC_PATH=${HOME}/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

Any help would be appreciated.

jsoverson commented 3 years ago

On my setup anyway, rustup component add rust-src puts the source in "$(rustc --print sysroot)/lib/rustlib/src/rust/library". There is no src directory, but racer works when pointed to that library dir.

$ export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/library"
$ racer complete std::io::B
MATCH BufRead,1781,10,path.../rustlib/src/rust/library/std/src/io/mod.rs,Trait,pub trait BufRead: Read
MATCH Bytes,2397,11,path.../rustlib/src/rust/library/std/src/io/mod.rs,Struct,pub struct Bytes<R>
MATCH BufReader,53,11,path.../rustlib/src/rust/library/std/src/io/buffered.rs,Struct,pub struct BufReader<R>
MATCH BufWriter,448,11,path.../rustlib/src/rust/library/std/src/io/buffered.rs,Struct,pub struct BufWriter<W: Write>

YMMV