Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacs-racer seems to have a different idea about RUST_SRC_PATH than the system #93

Open
ElectricCoffee opened this issue Nov 6, 2017 · 5 comments

Comments

@ElectricCoffee
Copy link

ElectricCoffee commented Nov 6, 2017

This is a bit of a curiosity.

I've set the RUST_SRC_PATH to point to the source directory:

$ echo $RUST_SRC_PATH
/home/coffee/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src

But racer insists that the variable is set to "/usr/local/src/rust/src" via this error:

The last racer command was:

$ cd /home/coffee/Documents/code/rust/word-gen/
$ export CARGO_HOME=/home/coffee/.cargo
$ export RUST_SRC_PATH=/usr/local/src/rust/src
$ /home/coffee/.cargo/bin/racer complete 2 14 /home/coffee/Documents/code/rust/word-gen/src/generator.rs /tmp/racer14648QqG

This command terminated with exit code 1.

stdout:

racer can't find the directory pointed to by the RUST_SRC_PATH variable ""/usr/local/src/rust/src"". Try using an absolute fully qualified path and make sure it points to the src directory of a rust checkout - e.g. "/home/foouser/src/rust/src".

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=/home/coffee/.cargo RUST_SRC_PATH=/usr/local/src/rust/src /home/coffee/.cargo/bin/racer complete 2 14 /home/coffee/Documents/code/rust/word-gen/src/generator.rs

Please report bugs on GitHub.

I have a feeling that it's emacs that is doing the re-exporting of RUST_SRC_PATH, thus clashing with the existing one.

I'm running Ubuntu 17.10, Emacs 25.2.2, Rust v. 1.21.0, and emacs-racer v. 1.2

@Wilfred
Copy link
Member

Wilfred commented Nov 12, 2017

How are you setting RUST_SRC_PATH? It sounds like you've set it in a shell and Emacs is ignoring it.

You could set racer-rust-src-path directly if you just want a quick fix.

The default logic is to either use RUST_SRC_PATH (in the shell/environment Emacs is running in), or failing that we try rustc --print sysroot, and failing that we fall back to /usr/local/src/rust/src.

@ElectricCoffee
Copy link
Author

I set it in my .bashrc file

@willbush
Copy link

@ElectricCoffee I suspect if you evaluate the lisp function (getenv "RUST_SRC_PATH") it will return nil. This the function you need to get working if you want racer.el to set racer-rust-src-path to your RUST_SRC_PATH for you. getenv, in part, searchs through the process-environment variable for the path. If you look through the content of that variable you'll probably won't see your path variable.

You should look at the section "Why am I getting a message about environment variables on startup?" here. I know you probably don't spacemacs, but the advice to not set environmental variables in your .bashrc might help you here. Short of that you probably just have a configuration issue that's not properly loading environmental variables.

@apiraino
Copy link

apiraino commented May 31, 2018

Confirming that if RUST_SRC_PATH is not set anywhere, racer stops behaving erratically (it occurred me sometimes). I stand corrected, in my case I did not download the nightly src files:
$ rust install nightly
$ rustup component add rust-src

However, still curious about the rest of my comment.

So, now I'm a bit confused: is the RUST_SRC_PATH env var needed at all or is it better to not set it? If the latter is true, the documentation should be amended consequently (and I'd gladly submit a tiny pr).

Perhaps related to racer-rust/racer#799

Opinions?

@kngwyu
Copy link
Collaborator

kngwyu commented Jun 1, 2018

@apiraino

is the RUST_SRC_PATH env var needed at all or is it better to not set it?

Now racer can work without RUST_SRC_PATH, but I think you have no problem if you set it manually.
But, anyway I think we have to update README, so it's great if you submit a PR for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants