racer-rust / racer

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

Path is not automatically detected on OSX #1125

Open adaschevici opened 4 years ago

adaschevici commented 4 years ago

Hi,

I've updated OSX to the last supplemental update and completion seems to have stopped working. the rust-src component path seems to no longer be detected accurately. Setting it manually seems to not work very well as it can't find libstd

it seems this path no longer exists: export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"

Versions: rustc 1.47.0-nightly (8e21bd063 2020-08-14) rustup 1.22.1 (b01adbbc3 2020-07-08) racer 2.1.37

Not sure what i am missing

greym0uth commented 4 years ago

It seems like on 2020-07-29 the src directory was removed and the library directory was introduced. 2020-07-28 build has the src directory, and 2020-07-29 has the library directory.

mapkts commented 4 years ago

I work around this by making RUST_SRC_PATH points to a stable release which do contains a src folder (something like .rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src).

adaschevici commented 4 years ago

@Jaden-Giordano as per @mapkts suggestion i did a manual install of the but libstd seems to be missing in the clone of the rustc repo as described in the manual install section of racer, so still seems like something is missing

jonas-hagen commented 4 years ago

Further, the libstd directory seems to be missing in nightly. This directory is used to validate the src path: https://github.com/racer-rust/racer/blob/a4bcf46c7a908eb53eeb69ec421c5ee44e879902/src/racer/util.rs#L535

So, I get the following error:

$ export RUST_SRC_PATH=~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/

$ racer complete 3 9 main.rs /tmp/racerABCDE
Unable to find libstd under RUST_SRC_PATH. N.B. RUST_SRC_PATH variable needs to point 
to the *src* directory inside a rust checkout e.g. "/home/foouser/src/rust/src". Current value 
""/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/libstd""

$ ls /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/
alloc         profiler_builtins          stdarch
backtrace     rtstartup                  term
core          rustc-std-workspace-alloc  test
panic_abort   rustc-std-workspace-core   unwind
panic_unwind  rustc-std-workspace-std
proc_macro    std

I did not find any resources on the renaming of these directories, maybe there are even more changes. Anybody else knows something about this?

Better title for this issue would maybe be "rust-src directories have been renamed in nightly" as it does not only affect MacOS.

sigmaSd commented 3 years ago

Looks like the new layout is already handled https://github.com/racer-rust/racer/blob/bc478759f9f7f6dacd9ec26e7905dc8724740797/src/racer/nameres.rs#L824 so maybe it just a matter of removing that assert.

sigmaSd commented 3 years ago

So its actually fixed in master https://github.com/racer-rust/racer/commit/e669f6b86c8df77eaa64cf00c0d14e30a9458c9e

xuyizhe commented 3 years ago

Fixed some related issues in 3bcf543f3d0237e5fa545c56b2d51f91207ee500 and https://github.com/racer-rust/emacs-racer/issues/144