You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On page 31 of the Kindle Edition of the book, the following example code from the book doesn't work on Windows:
use std::process::Command;
#[test]
fn runs() {
let mut cmd = Command::new("ls");
let res = cmd.output();
assert!(res.is_ok());
}
The reason is because there is no separate EXE file corresponding to ls on Windows.
Windows' ls command is actually an internal component of the powershell executable.
To fix it, what actually must be done is to pass "powershell" as the command and then give it "ls" as an argument.
Thus, the following code (in contrast), works on Windows:
use std::process::Command;
#[test]
fn runs() {
let mut cmd = Command::new("powershell");
cmd.arg("ls");
let res = cmd.output();
assert!(res.is_ok());
}
Perhaps this mistake was made by emulating Windows on Linux (which is not real Windows) or by not testing it on Windows at all.
Anyway, thanks for your time and for writing the book!
The text was updated successfully, but these errors were encountered:
Thanks for the comment! All my code examples worked using WSL1. I confess I didn't extensively test on Windows as I have used Unix-like operating systems for over 20 years and never have reason to use Windows. In chapter 7 (findr), I show how to use #[cfg(windows)] to conditionally compile code when on Windows, but chapter 1 is way to early to introduce such a concept.
On page 31 of the Kindle Edition of the book, the following example code from the book doesn't work on Windows:
The reason is because there is no separate EXE file corresponding to
ls
on Windows.Windows'
ls
command is actually an internal component of thepowershell
executable.To fix it, what actually must be done is to pass
"powershell"
as the command and then give it"ls"
as an argument.Thus, the following code (in contrast), works on Windows:
Perhaps this mistake was made by emulating Windows on Linux (which is not real Windows) or by not testing it on Windows at all.
Anyway, thanks for your time and for writing the book!
The text was updated successfully, but these errors were encountered: