rust-lang / rustlings

:crab: Small exercises to get you used to reading and writing Rust code!
https://rustlings.cool
MIT License
53.83k stars 10.13k forks source link

Stuck with 00_into/intro1.rs, no such command: 'clippy' #2057

Closed GwenTheKween closed 3 months ago

GwenTheKween commented 3 months ago

I just decided to try rustlings, and I can't run the first exercise. The output when I run rustlings is:

error: no such command: `clippy`

    View all installed commands with `cargo --list`
    Find a package to install `clippy` with `cargo search cargo-clippy`

Progress: [>---------------------------------------------------]   0/94 exercises
Current exercise: exercises/00_intro/intro1.rs

h:hint / l:list / q:quit ? 

Using the hint, there is a "cargo-clippy" package with version "0.0.0", but trying to install it gives me the following error:

➜  rustlings git:(main) ✗ cargo search cargo-clippy 
cargo-clippy = "0.0.0"         # A subcommand for cargo to perform linting on cargo projects. Can be used as a substitution for c…
(...)
➜  rustlings git:(main) ✗ cargo install cargo-clippy
    Updating crates.io index
error: could not find `cargo-clippy` in registry `crates-io` with version `*`

and trying to install just "clippy" manages to download and install all dependencies, but fails with the following error at the end:

error: failed to run custom build command for `clippy v0.0.302`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installvXHEFy/release/build/clippy-7b2a80354db5459c/build-script-build` (exit status: 1)
  --- stderr

  error: Clippy is no longer available via crates.io

  help: please run `rustup component add clippy-preview` instead

I'm not sure clippy-preview is the needed package, and I'd prefer to not litter my system with even more dependencies, considering cargo can't uninstall them properly.

How do I proceed? Also, please fix the hint on rustlings, and the dependencies

GwenTheKween commented 3 months ago

Oh, I forgot to mention, I'm running on Fedora 40, baremetal

mo8it commented 3 months ago

How did you install Rust?

GwenTheKween commented 3 months ago

sudo dnf install rust

mo8it commented 3 months ago

If you installed Rust using rustup, then all what you need to do is running rustup component add clippy.

I will add a hint to do this in the README. But if you installed Rust using rustup, then it should have installed Clippy too.

mo8it commented 3 months ago

sudo dnf install rust

Then please install clippy using sudo dnf install clippy

GwenTheKween commented 3 months ago

Thank you! This worked.

mo8it commented 3 months ago

I use Fedora myself (Silverblue). But using the official installation method is still the recommend one over using a package manager: https://www.rust-lang.org/tools/install