crate2nix
crate2nix copied to clipboard
Build fails with clap v4.0.22: missing dependency atty
Hi,
clap-rs switched from atty
to is-terminal
and I am on an old version still using atty
, which I cannot build with crate2nix.
➜ crate2nix-clap-atty git:(master) nix build -f Cargo.nix
error: builder for '/nix/store/4irmizhc2ifzijy7vni5p1l909pwv7z0-rust_clap-4.0.22.drv' failed with exit code 1;
last 10 log lines:
> error[E0433]: failed to resolve: use of undeclared crate or module `atty`
> --> src/output/fmt.rs:90:5
> |
> 90 | atty::is(stream)
> | ^^^^ use of undeclared crate or module `atty`
>
> error: aborting due to 15 previous errors
>
> Some errors have detailed explanations: E0432, E0433.
> For more information about an error, try `rustc --explain E0432`.
For full logs, run 'nix log /nix/store/4irmizhc2ifzijy7vni5p1l909pwv7z0-rust_clap-4.0.22.drv'.
error: 1 dependencies of derivation '/nix/store/ayxjfhsslabrgzg2s5gkvbqx6fg27kfj-rust_showbug-0.1.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/8sm2412v27b2psn41rhwqiyzqkypxhhb-all-workspace-members.drv' failed to build
➜ crate2nix-clap-atty git:(master)
Cargo.nix has been generated with crate2nix v0.10.0, built from
I made a small test project that shows the same behaviour: https://github.com/Panke/crate2nix-clap-atty
Maybe it has something to do with clap switching to is-terminal recently, but this is my first try with crate2nix so I can't tell. Updating (nix flake update && cargo update
) does not help and leads to:
➜ crate2nix-clap-atty git:(master) ✗ nix build -f Cargo.nix
error: builder for '/nix/store/bqs0kl0g2lxp5xqhgm0r2dvshj9lc6k6-rust_clap-4.0.29.drv' failed with exit code 1;
last 10 log lines:
> error[E0599]: no method named `is_terminal` found for struct `Stderr` in the current scope
> --> src/output/fmt.rs:88:45
> |
> 88 | Stream::Stderr => std::io::stderr().is_terminal(),
> | ^^^^^^^^^^^ method not found in `Stderr`
>
> error: aborting due to 15 previous errors
>
> Some errors have detailed explanations: E0432, E0433, E0599.
> For more information about an error, try `rustc --explain E0432`.
For full logs, run 'nix log /nix/store/bqs0kl0g2lxp5xqhgm0r2dvshj9lc6k6-rust_clap-4.0.29.drv'.
Am I doing it wrong?
I was debugging a similar thing and it seems that those two issues are related: https://github.com/kolloch/crate2nix/issues/129 it is associated with how is-terminal crate handles optional compilation based on cfg: https://github.com/sunfishcode/is-terminal/blob/main/src/lib.rs#L54-L73
For a quick fix you might disable color
feature in clap
The problem seems that clap uses "dep:" features. These were introduced in rust 1.60.0. Support in crate2nix was added in #252. However, after #264 noted this, only a release canidate was created by #270, and the version in nixpkgs is still version 0.10.0 and does not yet provide support for "dep:" features.
TL;DR use most recent version of crate2nix instead of nixpkgs version until 0.11.0 comes out