crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.28k stars 281 forks source link

Crossterm 0.28.0 on crates.io differs from this repo and cannot build on Linux/macOS #903

Closed gyscos closed 3 months ago

gyscos commented 3 months ago

Describe the bug

Trying to build crossterm 0.28.0 from crates.io leads to failures related to signal-hook-mio missing the support-v0_8 feature (and instead having support-v1_0).

Looking at the Cargo.toml from the crate downloaded from crates.io, it indeed differs from the one in this repository.

diff -w <(
    # The version from the git repo
    curl -sL https://raw.githubusercontent.com/crossterm-rs/crossterm/0.28/Cargo.toml
) <(
    # The version from crates.io
    curl -sL 'https://crates.io/api/v1/crates/crossterm/0.28.0/download' |
    tar Oxzf - crossterm-0.28.0/Cargo.toml.orig
)
84,86c84,86
< mio = { version = "0.8", features = ["os-poll"], optional = true }
< signal-hook-mio = { version = "0.2.3", features = [
<     "support-v0_8",
---
> mio = { version = "1.0", features = ["os-poll"], optional = true }
> signal-hook-mio = { version = "0.2.4", features = [
>     "support-v1_0",
93c93
< tokio = { version = "1.25", features = ["full"] }
---
> tokio = { version = "1.39", features = ["full"] }

The rest of the archive matches the current repository, only Cargo.toml and Cargo.lock differ. So essentially it switched mio from 0.8 to 1.0 in Cargo.toml, but did not actually change the code to support mio 1.0: https://github.com/crossterm-rs/crossterm/blob/5d50d8da62c5e034ef8b2787a771a2c0f9b3b2f9/src/event/source/unix/mio.rs#L4

To Reproduce

cargo new crossterm-test && cd crossterm-test
cargo add crossterm
cargo check

Output:

   Compiling libc v0.2.155
   Compiling autocfg v1.3.0
   Compiling parking_lot_core v0.9.10
   Compiling signal-hook v0.3.17
    Checking cfg-if v1.0.0
    Checking log v0.4.22
    Checking scopeguard v1.2.0
   Compiling rustix v0.38.34
    Checking smallvec v1.13.2
    Checking linux-raw-sys v0.4.14
    Checking bitflags v2.6.0
   Compiling lock_api v0.4.12
    Checking signal-hook-registry v1.4.2
    Checking mio v1.0.1
    Checking parking_lot v0.12.3
    Checking signal-hook-mio v0.2.4
    Checking crossterm v0.28.0
error[E0432]: unresolved import `signal_hook_mio::v0_8`
 --> /home/gyscos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossterm-0.28.0/src/event/source/unix/mio.rs:4:22
  |
4 | use signal_hook_mio::v0_8::Signals;
  |                      ^^^^ could not find `v0_8` in `signal_hook_mio`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `crossterm` (lib) due to 1 previous error

Expected behavior

Build succeeds.

Yanking 0.28.0 (or not? it doesn't build, but it's not exactly dangerous) and re-publishing the current git head as 0.28.1 would solve this issue.

Workaround

The use-dev-tty feature sounds like it could help by using rustix instead of mio, but it fails also for a different reason (#905).

OS

Terminal/Console

TimonPost commented 3 months ago

I'll make a 0.28.1 and can yank it once the newone is published.

TimonPost commented 3 months ago

published: https://crates.io/crates/crossterm/0.28.1