Unlesolved import sys

Hi. I'm trying to compile a project to get random number when I get a Char 'N' event.
But I'm getting errors 'unresolved import sys' and 'failed to resolve: maybe a missing crate sys?'.

My code is following:


extern crate sys;
use rand::Rng;
use termion::event::{Event, Key};
use srd::io::{stdout, stdin};

fn main() {
    let mut rng = rand::thread_rng();

    let stdin = stdin();
    for evt in stdin.events(){
    if evt.unwrap() == Event::Key(Key::Char('N'))){
        let dice = rng.gen_range(1..7);
        println!("{}", dice);


name = "dice"
version = "0.1.0"
edition = "2021"

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

rand = "0.8.0"
termion = "1"
sys = "0.0.0"

sys is not a crate I recognize.

Additionally, your code makes no reference to it whatsoever, so remove the extern crate line (which is usually not necessary in 2018+ edition), and remove it from your Cargo.Toml and work from there.

It's an empty placeholder, in fact.

I remove it from my Cargo.toml. But I can't get rid of errors.
What else can I do to remove the error?

Is this srd intentional, typo in code, or the result of not copy-pasting it here?

oh, sorry.
It's a typo. But after fixing the mistake, I still got the same error.

Have you also removed the extern crate sys; line?
Can you paste the actual error from the command line?

After dropping sys crate, fixing the typo mentioned above, fixing the syntax error and following the compiler suggestion to add missing import, code from your initial post compiles. Are you sure you haven't dropped the erroneous part form it?

1 Like

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.