Rustup: racer error in emacs on mac

Created on 11 May 2017  路  7Comments  路  Source: rust-lang/rustup

I submit this issue here because I suspect that this is related to rustup not being properly installed.

Here is the error output when racer wants to autocomplete in emacs:

The last racer command was:

$ cd /Users/stevenquarles/Box Sync/Rust Projects/Introductory Projects/2017may_hello/hello_world/
$ export CARGO_HOME=/Users/stevenquarles/.cargo
$ export RUST_SRC_PATH=/Users/stevenquarles/.cargo/registry/src
$ /Users/stevenquarles/.cargo/bin/racer complete 3 6 /Users/stevenquarles/Box Sync/Rust Projects/Introductory Projects/2017may_hello/hello_world/src/main.rs /var/folders/lr/pj46zqzs4c79v6vcmwt2005m0000gn/T/racer597X7v

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 ""/Users/stevenquarles/.cargo/registry/src/libstd""

No output on stderr.

The temporary file will have been deleted. You should be
able to reproduce the same output from racer with the
following command:

$ CARGO_HOME=/Users/stevenquarles/.cargo RUST_SRC_PATH=/Users/stevenquarles/.cargo/registry/src /Users/stevenquarles/.cargo/bin/racer complete 3 6 /Users/stevenquarles/Box Sync/Rust Projects/Introductory Projects/2017may_hello/hello_world/src/main.rs

Please report bugs on GitHub.

Another piece of information regarding my experience with rustup is that in the Terminal every time I begin a new session, rustup, cargo, rustc, etc. become undefined. Every time I want to use these variables I have to run source .profile or source .bashrc; (I tried putting the PATH variable in .bashrc as well.

I'm no expert at this kind of stuff, any help would be really great.

Most helpful comment

I am not sure how you installed rustup and the rest of toolchain, but on my machines adding the rust src:

rustup component add rust-src

Adds the rust source tree under the active toolchain which is typically:

~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

It seems you are trying to set RUST_SRC_PATH to be under .cargo/registry/src

All 7 comments

I am not sure how you installed rustup and the rest of toolchain, but on my machines adding the rust src:

rustup component add rust-src

Adds the rust source tree under the active toolchain which is typically:

~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

It seems you are trying to set RUST_SRC_PATH to be under .cargo/registry/src

If you are using the latest version of racer, you should be able to leave RUST_SRC_PATH unset, and it will figure it out automatically (as long as you have the sources installed as described above)

So in emacs and in rust-mode, every time, I start to type anything this error displays in the mini-buffer: eldoc error...

screenshot

I am not sure how you installed rustup and the rest of toolchain, but on my machines adding the rust src:

rustup component add rust-src

Adds the rust source tree under the active toolchain which is typically:

~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

It seems you are trying to set RUST_SRC_PATH to be under .cargo/registry/src

still no libstd.

rustup component add rust-src
info: component 'rust-src' is up to date
rustup component remove  rust-src
info: removing component 'rust-src'
rustup component add rust-src
info: downloading component 'rust-src'
ls /Users/fox/.cargo/registry/src/github.com-1ecc6299db9ec823/ |grep std
tokio-stdin-stdout-0.1.5
````


direct use git clone  will be ok.

git clone [email protected]:rust-lang/rust.git

```

How can it be closed? I cannot find the resolution and I get the same problem.

` $ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/username/.rustup

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.49.0-nightly (dd7fc54eb 2020-10-15)`

$ rustup component add rust-src info: component 'rust-src' is up to date

$ racer complete std::io::B 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/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd""

$ racer --version racer 2.1.39
So it is not fixed, obviously and it is not only a problem on MAC (using debian, here).

@ruffianeo If you are having this problem, it's a bug in racer, not in rustup. Please address your issue to them. All we can do is install the components we're given by the compiler team :D

Hello,

Racer module needs an update after changes in the rust path detailed above.

I've forked the main racer repository and added a patch so that it automatically detects if the old or new one should be used.
Also have requested to the maintainers a merge applying my changes.

Meanwhile, you can download a fixed races.el version which fixes the problem from here:
https://github.com/rodested/emacs-racer

Quick fix:

  1. download the races.el file
  2. overwrite the one in (as per my installation): ~/.emacs.d/elpa/26.3/develop/racer-20210119.225 with the downloaded one

Hope this helps

Was this page helpful?
0 / 5 - 0 ratings