Hi all,
I am trying to unpack some files using the windows "tar" command.
When I execute the following command in a command-prompt, it works exactly as I'd expect:
tar -xzvf "I:/Downloads/test_dir/mlops.zip" --strip-components=1 -C "I:/Downloads/test_dir/mlops/"
However, when I run this through a "command" in Rust, it throws an error, complaining about the target directory not being accessible tar: could not chdir to ' I:/Downloads/test_dir/mlops/'
.
This is the code I'm using to replicate the command:
let src_file = "I:/Downloads/test_dir/mlops.zip"';
let tgt_dir = "I:/Downloads/test_dir/mlops/";
let mut command = std::process::Command::new("tar");
command.args(
vec![
"-xzvf",
&src_file,
"--strip-components=1",
&format!("-C {tgt_dir}/")
]
);
let result = command.output()?;
if !result.status.success() {
println!("unpack failed:\n{:?}", std::str::from_utf8(&result.stderr)?);
}
the source-file and target-dir are actually converted from pathbufs, but I printed out the paths in the application and pasted them here instead for brevity.
Any ideas as to why process::Command might be executing things differently resulting in the error?