racer-rust / emacs-racer

Racer support for Emacs
399 stars 48 forks source link

Unable to find libstd under RUST_SRC_PATH #152

Open h3poteto opened 3 years ago

h3poteto commented 3 years ago

When I run racer in emacs, it says an error.

This command terminated with exit code 1.

stdout:

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/h3poteto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/libstd""

No output on stderr.
$ rustc --version
rustc 1.53.0 (53cb7b09b 2021-06-17)
$ pwd
/home/h3poteto/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
$ ls -lha
total 72K
drwxr-xr-x 18 h3poteto h3poteto 4.0K  6月 30 21:48 .
drwxr-xr-x  4 h3poteto h3poteto 4.0K  6月 30 21:48 ..
drwxr-xr-x  5 h3poteto h3poteto 4.0K  6月 30 21:48 alloc
drwxr-xr-x  8 h3poteto h3poteto 4.0K  6月 30 21:48 backtrace
drwxr-xr-x  5 h3poteto h3poteto 4.0K  6月 30 21:48 core
drwxr-xr-x  3 h3poteto h3poteto 4.0K  6月 30 21:48 panic_abort
drwxr-xr-x  3 h3poteto h3poteto 4.0K  6月 30 21:48 panic_unwind
drwxr-xr-x  4 h3poteto h3poteto 4.0K  6月 30 21:48 proc_macro
drwxr-xr-x  3 h3poteto h3poteto 4.0K  6月 30 21:48 profiler_builtins
drwxr-xr-x  2 h3poteto h3poteto 4.0K  6月 30 21:48 rtstartup
drwxr-xr-x  2 h3poteto h3poteto 4.0K  6月 30 21:48 rustc-std-workspace-alloc
drwxr-xr-x  2 h3poteto h3poteto 4.0K  6月 30 21:48 rustc-std-workspace-core
drwxr-xr-x  2 h3poteto h3poteto 4.0K  6月 30 21:48 rustc-std-workspace-std
drwxr-xr-x  5 h3poteto h3poteto 4.0K  6月 30 21:48 std
drwxr-xr-x  6 h3poteto h3poteto 4.0K  6月 30 21:48 stdarch
drwxr-xr-x  3 h3poteto h3poteto 4.0K  6月 30 21:48 term
drwxr-xr-x  3 h3poteto h3poteto 4.0K  6月 30 21:48 test
drwxr-xr-x  3 h3poteto h3poteto 4.0K  6月 30 21:48 unwind
$ find ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu -name "libstd"

There is no libstd in library directory. On the contrary, there is no file called libstd in the /.rustup` directory.

This issue is similar https://github.com/racer-rust/emacs-racer/issues/146 .

viseztrance commented 3 years ago

I had the same issue just moments ago, and I even tried to clone the rust source repo.

So I did some investigating, and by running git log -- src/libstd I noticed the folder was moved.

Given I had rust cloned in ~/Sources/rust/src, I was trying (setq racer-rust-src-path "~/Sources/rust/src"). Therefore based on the git commit, I changed the path to (setq racer-rust-src-path "~/Sources/rust/library") and it worked!

h3poteto commented 3 years ago

Thank you. But I have to clone rust source code according to your method.

How should emacs-racer solve it? I'm grateful for the workaround, but I hope the emacs-racer will eventually solve it.

ayrat555 commented 3 years ago

it is already handled by the emacs-racer - https://github.com/racer-rust/emacs-racer/blob/master/racer.el#L93

The problem I had is that I set a custom RUST_PATH in my .zshrc file. (https://github.com/racer-rust/emacs-racer/blob/master/racer.el#L88)