Open sashkachan opened 7 years ago
I set the variable to "" (empty string) and RUST_SRC_PATH was implicitly set. I reset it to original value, which defaulted to
$(rustc --print sysroot)/lib/rustlib/src/rust/src
Does it mean when I change the environment with rustup I will have to update the racer-rust-src-path to?
Sorry, I'm slightly confused by which variables you're setting. Had you explicitly set the elisp variable racer-rust-src-path
or the environment variable RUST_SRC_PATH
? What value did Emacs say racer-rust-src-path
was set to?
(You can view this M-x ielm RET racer-rust-src-path RET
.)
This is probably obvious, but RUST_SRC_PATH=/Users/sashka/projects/rust-examples/hello_world/src
is wrong -- it should be the path to the stdlib source code, not the code for your project.
Does it mean when I change the environment with rustup I will have to update the racer-rust-src-path too?
If you really want to see the exact source code of the stdlib when you jump to a definition, yes. I don't generally bother changing it, I'm happy with it always pointing to nightly's stdlib code.
I have not set RUST_SRC_PATH explicitly (and I checked, it wasn't in my ENV), so it wasn't set in emacs either.
I then set the racer-rust-src-path to "" (as I assumed it will be deduced automatically when the mode is engaged) but I get the error and racer-debug produces the output in the original post.
I expected if I reset "racer-rust-src-path" to be empty, it will be reset to the output of $(rustc --print sysroot)/lib/rustlib/src/rust/src
, but it doesn't seem to be the case?
I think it fails on this promise (from customise-variable racer-rust-src-path)
If $RUST_SRC_PATH is not set, look for rust source in rustup’s install directory.
Note that an empty string is truthy in elisp, so you should set the variable to nil if you want to reset it.
@alex-glv I just went through the same exercise. Setting the path to nil
in with custom-set-variable
did not work. I had to manually delete the line from ~/.emacs.d/custom.el
for it to take effect. On next startup, the path was automatically setup.
I was just getting racer set up and hit this issue too. In the hopes I may give someone else a workaround, here's what I did:
Install rust sources (rustup component add rust-src
)
Use rustc's knowledge of its own environment to configure racer's source path variable:
(setq racer-rust-src-path
(concat (string-trim
(shell-command-to-string "rustc --print sysroot"))
"/lib/rustlib/src/rust/src"))
I use use-package
; here's a more complete snippet of my racer configuration:
(use-package racer
:requires rust-mode
:init (setq racer-rust-src-path
(concat (string-trim
(shell-command-to-string "rustc --print sysroot"))
"/lib/rustlib/src/rust/src"))
:config
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
(add-hook 'racer-mode-hook #'company-mode))
add (require 'subr-x) to use string-trim for someone occur this error
Helped me: export RUST_SRC_PATH=$(rustc --print sysroot)/lib/rustlib/src/rust/library
Prior to running the project, I checked that src is installed, and I get sources under
From the description of Racer Rust Src Path it says: If $RUST_SRC_PATH is not set, look for rust source in rustup’s install directory.
Which I expected to happen, but on first completion attempt racer-debug claims that var exported is
Is it expected behaviour?
Thanks!