rust-cli / book

Documentation on how to use the Rust Programming Language to develop commandline applications
https://rust-cli.github.io/book/index.html
MIT License
816 stars 108 forks source link

First implementation of grrs fails with error[E0599] #223

Closed Raghav-Bell closed 1 year ago

Raghav-Bell commented 1 year ago

Rust version: rustc 1.70.0 Clap version : 4.3.19 OS: Microsoft Windows [Version 10.0.22621.1992] First implementation of grrs (Chapter 1.3) shown in the listing here. Following is the detailed error:

    Checking grrs v0.1.0 (PATH)
error: cannot find derive macro `Parser` in this scope
 --> src\main.rs:5:11
  |
5 | # [derive(Parser)]
  |           ^^^^^^
  |
note: `Parser` is imported here, but it is only a trait, without a derive macro
 --> src\main.rs:3:5
  |
3 | use clap::Parser;
  |     ^^^^^^^^^^^^

error[E0599]: no function or associated item named `parse` found for struct `Cli` in the current scope
  --> src\main.rs:11:20
   |
6  | struct Cli{
   | ---------- function or associated item `parse` not found for this struct
...
11 |     let args =Cli::parse();
   |                    ^^^^^ function or associated item not found in `Cli`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following traits define an item `parse`, perhaps you need to implement one of them:
           candidate #1: `Parser`
           candidate #2: `TypedValueParser`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `grrs` (bin "grrs") due to 2 previous errors
Raghav-Bell commented 1 year ago

I got the bug i.e clap crate installation. This bug can be easily resolved by adding clap = { version = "4.0", features = ["derive"] } in Cargo.tomlor running cargo add clap --features derive in the project directory.