No such file or directory (os error 2)

here's the source code

use std::process::Command;

fn main() {
    match Command::new("git status").output() {
        Ok(url) => {
            println!("{:?}", String::from_utf8(url.stdout));
        }
        Err(e) => {
            eprintln!("{e}");
        }
    }
}

idk why it prints out No such file or directory (os error 2)

the full repo is here GitHub - HomyeeKing/rust-repo

The way you have defined the Command, it is thinking git status is the executable being called, which results in the file not found. What you really want to say is that git is the command while status is the arg. So you should use: Command::new("git").arg("status").output().

It helps. Thanks a lot!

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.