badboy / mdbook-toc

A preprocessor for mdbook to add inline Table of Contents support.
Mozilla Public License 2.0
163 stars 20 forks source link

Cannot compile mdbook-toc v0.10.0 due to the failure to import `clap::crate_version` #30

Closed rina23q closed 1 year ago

rina23q commented 1 year ago

I could not compile mdbook-toc v0.10.0 because it failed to import clap::crate_version with the following error message. The full build log is available here.

Compiling mdbook-toc v0.10.0
  error[E0432]: unresolved import `clap::crate_version`
   --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-toc-0.10.0/src/bin/mdbook-toc.rs:6:12
    |
  6 | use clap::{crate_version, Arg, ArgMatches, Command};
    |            ^^^^^^^^^^^^^ no `crate_version` in the root

  error: cannot determine resolution for the macro `crate_version`
    --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-toc-0.10.0/src/bin/mdbook-toc.rs:16:18
     |
  16 |         .version(crate_version!())
     |                  ^^^^^^^^^^^^^
     |
     = note: import resolution is stuck, try simplifying macro imports

I think the problem is simply missing to include the feature flag in the Cargo.toml.

The doc of clap says that you need to enable the crate feature cargo to use clap::crate_version. I see it's currently missing in the Cargo.toml file of the project. We can confirm the feature cargo is not enabled by the default in their Cargo.toml.