Warning
This post was published 50 days ago. The information described in this article may have changed.
I run my program as ,
Command::new("./myprogram")
.current_dir("/bin")
.spawn()
.expect("ls command failed to start");
It works without any problem, however if I port the above code to Windows like,
Command::new(".\\myprogram")
.current_dir("C:\\bin")
.spawn()
.expect("ls command failed to start");
It can't start the program and Rust is reporting that the file not found. However, if I provide a full path to my program, like,
Command::new("C:\\bin\\myprogram")
.current_dir("C:\\bin")
.spawn()
.expect("ls command failed to start");
It starts normally. If I try to start the same program in Bash or cmd using .\myprogram, it starts on both systems. I think such Rust behavior is inconsistent. I still hope I missed something.
9 posts - 5 participants
🏷️ rust_feed