Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

clap derive macro Error Example

Putting this one here for anyone searching for the error message:

error: cannot find derive macro `Parser` in this scope
  --> src/main.rs:10:17
   |
10 | #[derive(Debug, Parser)]
   |                 ^^^^^^
   |
note: `Parser` is imported here, but it is only a trait, without a derive macro
  --> src/main.rs:4:5
   |
4  | use clap::Parser;
   |     ^^^^^^^^^^^^

error: cannot find attribute `clap` in this scope
  --> src/main.rs:13:7
   |
13 |     #[clap(short, long)]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute


The solution for me with this message was to update
my `Cargo.toml`` file from:

Code

clap = 4.3.10"

To:

Code

clap = { version = "4.3.10", features = ["derive"] }