Process Command No such file or directory

macos, does anyone knows why this code failes?

Thanks,

thread 'main' panicked at src/bin/a1.rs:9:14:
command failed to start: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
use std::{path::Path, process::Command};

fn main() {
    let dir = "/Applications";
    if Path::new(dir).exists() {
        Command::new("ls")
            .env("PATH", dir)
            .status()
            .expect("command failed to start");
    }
}

oh I know, because path is updated, then ls can't found...

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.