Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building from source missing clap derive macro #19

Open
mwly opened this issue Oct 24, 2023 · 2 comments
Open

Building from source missing clap derive macro #19

mwly opened this issue Oct 24, 2023 · 2 comments

Comments

@mwly
Copy link

mwly commented Oct 24, 2023

When Cloning this Repo and building from source i got
Parser is imported here, but it is only a trait, without a derive macro

Adding the solution from this stackoverflow thread helped
https://stackoverflow.com/a/69898700

I didn't open a PR because you might very well have a reason not to enable the flag.

full Error:

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

error: cannot find attribute `clap` in this scope
  --> src/bin/aascheck.rs:18:3
   |
18 | #[clap(
   |   ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

error: cannot find attribute `clap` in this scope
  --> src/bin/aascheck.rs:23:7
   |
23 |     #[clap(parse(from_os_str))]
   |       ^^^^
   |
   = note: `clap` is in scope, but it is a crate, not an attribute

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

error[E0599]: no function or associated item named `parse` found for struct `Opts` in the current scope
  --> src/bin/aascheck.rs:55:21
   |
22 | struct Opts {
   | ----------- function or associated item `parse` not found for this struct
...
55 |     let opt = Opts::parse();
   |                     ^^^^^ function or associated item not found in `Opts`
   |
   = 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`
           candidate #3: `object::read::coff::file::CoffHeader`
           candidate #4: `object::read::elf::file::FileHeader`
           candidate #5: `object::read::macho::file::MachHeader`
           candidate #6: `object::read::pe::file::ImageNtHeaders`
           candidate #7: `time::parsing::parsable::sealed::Sealed`
           candidate #8: `nom::internal::Parser`
           candidate #9: `nom::sequence::Tuple`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `basyx-rs` (bin "aascheck") due to 5 previous errors
error: failed to compile `basyx-rs v0.2.1 (~/SRC/Basyx/basyx-rust-sdk)`, intermediate artifacts can be found at `~/SRC/Basyx/basyx-rust-sdk/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
@jh-isw
Copy link
Contributor

jh-isw commented Nov 7, 2023

Thanks for the information. I'll have a look as soon as possible.

What's your output of rustc --version?

@jh-isw
Copy link
Contributor

jh-isw commented Nov 7, 2023

Looks like you used cargo install --path . as documented. I noticed, it uses different crate versions than the one specified in the Cargo.toml, that are used when running cargo build and the crates aren't compatible.

cargo install --locked --path . uses the crates that are in the Cargo.lock and this worked. Or update the dependencies.

I see you figured the solution out on your own. Thanks for letting us know anyways!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants