racer-rust / emacs-racer

Racer support for Emacs
399 stars 48 forks source link

Unable to find libstd under RUST_SRC_PATH. #146

Closed PlumpHip closed 3 years ago

PlumpHip commented 3 years ago

% 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 ""/nix/store/fjghknnd4x9zpgx6hxznaiw6c7y0jr2s-rust-1.47.0-2020-10-07-18bf6b4f0/lib/rustlib/src/rust/library/libstd""

I use nix Mozilla-rust-overlay stable

  nixpkgs.latest.rustChannels.stable.rust.override {
      extensions = [ #
      # "lldb-preview"
      "clippy-preview"
      # "miri-preview"
      "rls-preview"
      # "rust-analyzer-preview"
      "rustfmt-preview"
      "llvm-tools-preview"
      "rust-analysis"
      "rust-std"
      "rustc-dev"
      # "rustc-docs"
      "rust-src"

      ]

Thanks

SkamDart commented 3 years ago

Same as above but a full shell.nix for repro.

with import <nixpkgs> {};

let
  crust = (rustChannels.stable.rust.override { extensions = [ "rust-src" "rust-analysis" ]; });
in
stdenv.mkDerivation {
  name = "repro";
  buildInputs = [ crust rustracer ];
  RUST_SRC_PATH = "${crust}/lib/rustlib/src/rust/src";
}
PlumpHip commented 3 years ago

@SkamDart hmm;; Thank you for your answer, but I can't.

maybe necessary shell.nix & buildInputs = [ crust rustracer ]; ?

Is it possible to do this only with a local nix project? (I haven't tried it.)

I want a simple global, https://github.com/racer-rust/emacs-racer/issues/140

I'll have to give up nix provisioning and do it manually. T_T. Still, thank you so much for telling me the local method. I wanted to know.

PlumpMath commented 3 years ago

I solved this problem. Reason is racer latest version. Cargo install racer. THANKS.

udalrich commented 3 years ago

This is failing on Mac OS Catalina.

$ rustup self update
info: checking for self-updates
  rustup unchanged - 1.23.1
$ rustup component add rust-src
info: component 'rust-src' is up to date
$ cargo +nightly install racer
    Updating crates.io index
  Installing racer v2.1.43
   Compiling libc v0.2.85
...
error[E0658]: use of unstable library feature 'array_value_iter'
   --> /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_arena-702.0.0/src/lib.rs:134:40
    |
134 | impl<T, const N: usize> IterExt<T> for std::array::IntoIter<T, N> {
    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #65798 <https://github.com/rust-lang/rust/issues/65798> for more information
    = help: add `#![feature(array_value_iter)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'array_value_iter_slice'
   --> /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_arena-702.0.0/src/lib.rs:144:18
    |
144 |             self.as_slice().as_ptr().copy_to_nonoverlapping(start_ptr, len);
    |                  ^^^^^^^^
    |
    = note: see issue #65798 <https://github.com/rust-lang/rust/issues/65798> for more information
    = help: add `#![feature(array_value_iter_slice)]` to the crate attributes to enable

error: aborting due to 2 previous errors
$ uname -a
Darwin my-mac 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64

Although the issue might be that the installation instructions don't cause libstd to be installed:

$ find ~/.rustup -name libstd
$

Running M-x racer-debug does show that RUST_SRC_PATH is set to a directory that exists. But the only file in that directory is the llvm-project directory.

udalrich commented 3 years ago

A workaround (at least on a Mac) is to customize racer-rust-src-path. Racer had inferred it to be <stuff>/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src. Changing the last element to library fixed made it work for me. There are comments elsewhere on the net that rust changed where it installs system files, and racer has not caught up to that yet.

b-naber commented 3 years ago

I cannot get this to work. Neither re-installing racer not changing racer-rust-src-path works for me. Racer tries to find libstd, that file doesn't exist in the current rust installation, the standard library is named std not libstd. Is this a problem caused by emacs-racer or racer itself?

Wilfred commented 3 years ago

143 should fix this, but please reopen if you still have issues.