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

Cannot build crossterm 28.1 with use-dev-tty + event-stream features #935

Open
apanloco opened this issue Oct 10, 2024 · 1 comment
Open

Comments

@apanloco
Copy link

When enabling both use-dev-tty feature and event-stream feature, latest crossterm 28.1 fails to build. This is a complete example of how to reproduce the build error:

~ ❯ cargo init crosstermtest && cd crosstermtest
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
~/crosstermtest master* ❯ cargo add crossterm --features use-dev-tty,event-stream
    Updating crates.io index
      Adding crossterm v0.28.1 to dependencies
             Features:
             + bracketed-paste
             + event-stream
             + events
             + filedescriptor
             + use-dev-tty
             + windows
             - libc
             - serde
    Updating crates.io index
     Locking 44 packages to latest compatible versions
      Adding hermit-abi v0.3.9 (latest: v0.4.0)
      Adding linux-raw-sys v0.4.14 (latest: v0.6.5)
      Adding wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.3+wasi-0.2.2)
      Adding windows-sys v0.52.0 (latest: v0.59.0)
~/crosstermtest master* ❯ cat Cargo.toml | grep crossterm
name = "crosstermtest"
crossterm = { version = "0.28.1", features = ["use-dev-tty", "event-stream"] }
~/crosstermtest master* ❯ cargo build
   Compiling libc v0.2.159
   Compiling proc-macro2 v1.0.87
   ... (cut)
   Compiling filedescriptor v0.8.2
   Compiling crossterm v0.28.1
error[E0599]: no variant or associated item named `new` found for enum `FileDesc` in the current scope
   --> /home/da/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossterm-0.28.1/src/event/source/unix/tty.rs:188:36
    |
188 |                 let fd = FileDesc::new(self.wake_pipe.receiver.as_raw_fd(), false);
    |                                    ^^^ variant or associated item not found in `FileDesc<'_>`
    |
   ::: /home/da/.cargo/registry/src/index.crates.io-6f17d22bba15001f/crossterm-0.28.1/src/terminal/sys/file_descriptor.rs:30:1
    |
30  | pub enum FileDesc<'a> {
    | --------------------- variant or associated item `new` not found for this enum
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `new`, perhaps you need to implement it:
            candidate #1: `parking_lot_core::thread_parker::ThreadParkerT`

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

rucoder commented Oct 24, 2024

@apanloco adding libc feature fixes the problem. While mirgating to rastix, new method was not impemented here

#[cfg(not(feature = "libc"))]
impl FileDesc<'_> {
    pub fn read(&self, buffer: &mut [u8]) -> io::Result<usize> {
        let fd = match self {
            FileDesc::Owned(fd) => fd.as_fd(),
            FileDesc::Borrowed(fd) => fd.as_fd(),
        };
        let result = rustix::io::read(fd, buffer)?;
        Ok(result)
    }

    pub fn raw_fd(&self) -> RawFd {
        match self {
            FileDesc::Owned(fd) => fd.as_raw_fd(),
            FileDesc::Borrowed(fd) => fd.as_raw_fd(),
        }
    }
}

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