divan icon indicating copy to clipboard operation
divan copied to clipboard

Incorrect clap dependency requirement

Open polazarus opened this issue 4 months ago • 1 comments

When compiling a project with the minimal versions of the dependencies, I found a miscompilation due to Divan:

   --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/divan-0.1.21/src/cli.rs:1:66
    |
  1 | use clap::{builder::PossibleValue, value_parser, Arg, ArgAction, ColorChoice, Command, ValueEnum};
    |                                                                  ^^^^^^^^^^^ private enum
    |
note: the enum `ColorChoice` is defined here
   --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/clap-4.0.0/src/lib.rs:109:16
    |
109 | pub(crate) use crate::util::color::ColorChoice;
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: import `ColorChoice` directly
    |
  1 | use clap::{builder::PossibleValue, value_parser, Arg, ArgAction, clap::util::color::ColorChoice, Command, ValueEnum};
    |                                                                  +++++++++++++++++++

error[E0603]: enum `ColorChoice` is private
   --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/divan-0.1.21/src/divan.rs:5:11
    |
  5 | use clap::ColorChoice;
    |           ^^^^^^^^^^^ private enum
    |
note: the enum `ColorChoice` is defined here
   --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/clap-4.0.0/src/lib.rs:109:16
    |
109 | pub(crate) use crate::util::color::ColorChoice;
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: import `ColorChoice` directly
    |
  5 | use clap::util::color::ColorChoice;
    |           +++++++++++++

At first in clap 4, ColorChoice was dependent on the color feature... :facepalm:

You can use the nightly -Z minimal-versions or the add-on "cargo minimal-versions" to check for this kind of dependency error.

polazarus avatar Oct 28 '25 07:10 polazarus

At first in clap 4, ColorChoice was dependent on the color feature... 🤦

So glad I randomly decided to read this issue, that is quite funny

Rolv-Apneseth avatar Nov 07 '25 11:11 Rolv-Apneseth