'sys' crate is missing

My project was working fine until I updated my Cargo.toml file to use tui = "0.16"
crossterm = "0.19" as dependencies. When I tried to run cargo build on the file, I got this output in the terminal.

error[E0433]: failed to resolve: maybe a missing crate `sys`?
  --> C:\Users\shred\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\lib.rs:24:9
   |
24 | pub use sys::size::terminal_size;
   |         ^^^ maybe a missing crate `sys`?
   |
   = help: consider adding `extern crate sys` to use the `sys` crate

error[E0433]: failed to resolve: maybe a missing crate `sys`?
  --> C:\Users\shred\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\lib.rs:27:9
   |
27 | pub use sys::tty::{is_tty, get_tty};
   |         ^^^ maybe a missing crate `sys`?
   |
   = help: consider adding `extern crate sys` to use the `sys` crate

error[E0433]: failed to resolve: maybe a missing crate `sys`?
 --> C:\Users\shred\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:5:5
  |
5 | use sys::tty::get_tty;
  |     ^^^ maybe a missing crate `sys`?
  |
  = help: consider adding `extern crate sys` to use the `sys` crate

error[E0433]: failed to resolve: maybe a missing crate `sys`?
  --> C:\Users\shred\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:28:5
   |
28 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
   |     ^^^ maybe a missing crate `sys`?
   |
   = help: consider adding `extern crate sys` to use the `sys` crate

error[E0432]: unresolved import `sys`
  --> C:\Users\shred\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:29:5
   |
29 | use sys::Termios;
   |     ^^^ maybe a missing crate `sys`?
   |
   = help: consider adding `extern crate sys` to use the `sys` crate

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `termion` due to 5 previous errors
warning: build failed, waiting for other jobs to finish...

Here is the cargo.toml file that caused this.

[package]
name = "fallout_terminal"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ring = "0.16.20"
rand = "0.8.4"
crossterm = "0.19"
tui = "0.16"

When I rolled back to a earlier version of the project,I no longer encountered these errors, so the new libraries are clearly causing it. However,I don't see any dependency conflicts that should be causing this to happen? I'm very new to Rust,so is there something I'm missing?

The termion crate has a sys module that is only configured for unix or redox targets:
https://docs.rs/crate/termion/1.5.6/source/src/lib.rs

So I think this is coming through your tui dependency, which defaults to a termion backend that won't work on Windows. But it looks like you want crossterm, so try:

tui = { version = "0.16", default-features = false, features = ["crossterm"] }

which can also be expanded like:

[dependencies.tui]
version = "0.16"
default-features = false
features = ["crossterm"]
3 Likes

This fixes the problem, and the project is able to build,but is there a way to implement this so I can access tui features in Windows, or should I just write this on a unix based OS?

What features are you missing with tui+crossterm?

tui can use termion or crossterm; you pick one, not both. crossterm works on Windows and termion doesn't.

Not the cause of your problem, but I notice you seem to be using an older version (0.19) of crossterm - latest is 0.26.1

Gotcha,I assumed that the default-features flag being set to false would disable the features of tui I needed,but that is not the case. Thanks for your time.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.