racer-rust / racer

Rust Code Completion utility
MIT License
3.36k stars 278 forks source link

`cargo +nightly install racer` won't build (v 2.2 +), could not find `rust_ast` (and others) in registry `crates-io` with version `*` #1178

Closed stradicat closed 2 years ago

stradicat commented 2 years ago

Hello!

New rustacean here.

I tried building racer on a newly deployed dev machine yesterday, but the process couldn't be completed. I followed the same procedure as in other dev machines, but in this particular case, I get the following error message:

   Compiling racer v2.2.1
error[E0463]: can't find crate for `rustc_ast`
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/lib.rs:16:1
   |
16 | extern crate rustc_ast;
   | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_ast_pretty`
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/lib.rs:17:1
   |
17 | extern crate rustc_ast_pretty;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_data_structures`
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/lib.rs:18:1
   |
18 | extern crate rustc_data_structures;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_errors`
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/lib.rs:19:1
   |
19 | extern crate rustc_errors;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_parse`
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/lib.rs:20:1
   |
20 | extern crate rustc_parse;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
   |
   = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

[...]

error[E0412]: cannot find type `PatKind` in this scope
   --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/ast_types.rs:306:34
    |
306 |     pub(crate) fn from_ast(pat: &PatKind, scope: &Scope) -> Self {
    |                                  ^^^^^^^ not found in this scope

error[E0412]: cannot find type `GenericBounds` in this scope
   --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/ast_types.rs:736:18
    |
736 |         bounds: &GenericBounds,
    |                  ^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `TraitRef` in this scope
   --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/ast_types.rs:993:25
    |
989 | impl ImplHeader {
    |     - help: you might be missing a type parameter: `<TraitRef>`
...
993 |         otrait: &Option<TraitRef>,
    |                         ^^^^^^^^ not found in this scope

error[E0412]: cannot find type `TyKind` in this scope
    --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/ast_types.rs:1060:34
     |
1060 | pub(crate) fn get_self_path(ty: &TyKind, scope: &Scope) -> Option<Path> {
     |                                  ^^^^^^ not found in this scope

error[E0412]: cannot find type `BinOpKind` in this scope
    --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/nameres.rs:2721:11
     |
2721 |     node: BinOpKind,
     |           ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `LitIntType` in this scope
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/primitive.rs:61:36
   |
61 |     pub(crate) fn from_litint(lit: LitIntType) -> Self {
   |                                    ^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `BinOpKind` in this scope
  --> /home/adminifis/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.2.1/src/racer/typeinf.rs:25:38
   |
25 | pub(crate) fn get_operator_trait(op: BinOpKind) -> &'static str {
   |                                      ^^^^^^^^^ not found in this scope

Some errors have detailed explanations: E0405, E0412, E0425, E0433, E0463.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `racer` due to 275 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `racer v2.2.1`, intermediate artifacts can be found at `/tmp/cargo-installYTQMSq`

My standard rust installation follows this procedure:

curl --compressed --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; rustup toolchain install nightly; rustup +stable component add clippy rls rust-analysis rustfmt rust-src rustc-dev llvm-tools-preview; rustup +nightly component add clippy rls rust-analysis rustfmt rust-src rustc-dev llvm-tools-preview; cargo +nightly install racer; cargo install cargo-edit cargo-audit mdbook cargo-update cargo-outdated

The supposedly missing components, according to the error message, are already installed. I completely removed rust and reinstalled from scratch, the error persists.

What would you suggest I do to debug?

calebcartwright commented 2 years ago

Hello!

New rustacean here.

Welcome :wave:

First want to note that racer is essentially no longer maintained nor supported, and users should look at using Rust Analyzer instead.

If you do still want/need to build racer from source, be sure to follow the installation instructions in https://github.com/racer-rust/racer#current-nightly-rust and that you specify the correct toolchain when issuing build commands. The error is indicative of trying to compile racer with a toolchain that doesn't have the required components installed.

Racer, as well as many of the official tools/components like clippy and friends, make use of the compiler internals in a way that makes them comparatively difficult to compile from source as compared to a crate from crates.io. This unusual set of circumstances not only requires building on nightly, but typically a specific version can only be compiled with a specific set of nightly toolchains.

If you're still hitting issues with a recent nightly that has the requisite components, then your best bet would be to go back to a known-good nightly, as specified in the toolchain file in the repo root

stradicat commented 2 years ago

Thanks for the heads-up, @calebcartwright!

I'm going with rust-analyzer instead then.