racer-rust / emacs-racer

Racer support for Emacs
399 stars 48 forks source link

racer looks for libstd under rust/src, but it's not there #142

Closed philshafer closed 3 years ago

philshafer commented 3 years ago

Per the instructions, I've done the "rustup component add rust-src", but the ~/.rustup/toolchain/*/lib/rustlib/src/rust/directory has no "src" subdirectory. I've "git cloned"d the real sources into this directory, but there's no "libstd" directory.

Where is "libstd" supposed to come from? I do see a "library/std" under the rust git clone, but no libstd.

Thanks, Phil

Additional details:

I've not set racer-rust-src-path; it has the value:

"/Users/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src"
% pwd
/Users/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust
% git remote show origin
* remote origin
  Fetch URL: https://github.com/rust-lang/rust.git
  Push  URL: https://github.com/rust-lang/rust.git
  HEAD branch: master
  Remote branches:
    LeSeulArtichaut-patch-1 tracked
    auto                    tracked
    beta                    tracked
    master                  tracked
    stable                  tracked
    temp-dev-stable         tracked
    try                     tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
% ls
CODE_OF_CONDUCT.md  LICENSE-MIT     library/
CONTRIBUTING.md     README.md       rustfmt.toml
COPYRIGHT       RELEASES.md     src/
Cargo.lock      compiler/       triagebot.toml
Cargo.toml      config.toml.example x.py*
LICENSE-APACHE      configure*
% find . -name libstd

Same results where run by hand:

% env RUST_SRC_PATH=`pwd`/src /Users/phil/.cargo/bin/racer find-definition 20 38 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rs
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/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd""
%
The last racer command was:

$ cd /Volumes/case/work/foghorn/rust/sxd-xpath/
$ export CARGO_HOME=/Users/phil/.cargo
$ export RUST_SRC_PATH=/Users/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src
$ /Users/phil/.cargo/bin/racer find-definition 20 38 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rsw /var/folders/j6/xzl2vjp53g38g6prvblcyhdw0000gn/T/racer6QJxx9

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/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd""

Process *async-racer* exited abnormally with code 1

stderr:

Process *async-racer* stderr finished

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/phil/.cargo RUST_SRC_PATH=/Users/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src /Users/phil/.cargo/bin/racer find-definition 20 38 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rs

Please report bugs on GitHub.
ghost commented 3 years ago

See also #140 and #141

philshafer commented 3 years ago

There's no "libstd" under rust/library, but this does silence the error.

Unfortunately, racer still doesn't work, even for items in the current source tree. I get "No definition found" for any token in emacs:

The last racer command was:

$ cd /Volumes/case/work/foghorn/rust/sxd-xpath/
$ export CARGO_HOME=/Users/phil/.cargo
$ export RUST_SRC_PATH=/Users/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library
$ /Users/phil/.cargo/bin/racer find-definition 26 22 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rs /var/folders/j6/xzl2vjp53g38g6prvblcyhdw0000gn/T/racercX3svV

This command terminated with exit code 0.

stdout:

END

Process *async-racer* finished

stderr:

Process *async-racer* stderr finished

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/phil/.cargo RUST_SRC_PATH=/Users/phil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library /Users/phil/.cargo/bin/racer find-definition 26 22 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rs

Please report bugs on GitHub.

When I run via command line, I just get "END":

% env RUST_SRC_PATH=`pwd`/rust/library/ /Users/phil/.cargo/bin/racer -i text find-definition 20 38 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rs
END

Is there an older or non-nightly I could install?

Thanks, Phil

xuyizhe commented 3 years ago

@philshafer I fixed the same issues in #144.

philshafer commented 3 years ago

This is a nice fix for setting the RUST_SRC_PATH, but even with that I'm seeing "racer find-definition" fail to return useful information, as you see when it's run via command line:

% env RUST_SRC_PATH=`pwd`/rust/library/ /Users/phil/.cargo/bin/racer -i text find-definition 20 38 /Users/phil/work/foghorn/rust/sxd-xpath/src/lib.rs
END

I'm not sure why using /library/ silences the error, even though there's no /library/libstd/ directory.

Thanks, Phil

philshafer commented 3 years ago

Doh! never mind; my test case was in a doc comment. It's working on normal code.

Thanks, Phil