Closed
Description
The old resolver would try to run broken symlinks. The new one skips them and continues searching.
To test this I created the simplest program that will run successfully.
Z:\test> mkdir exists
Z:\test> cd exists
Z:\test\exists> gc exe_exists.rs
fn main() {}
Z:\test\exists> rustc exe_exists.rs
Z:\test\exists> cd ..
Z:\test>
Then I used the following test program:
// run_symlink.rs
use std::process::Command;
use std::os::windows::fs::symlink_file;
use std::env;
use std::fs;
fn main() -> std::io::Result<()> {
// Get the directory of the working exe
let mut exists = env::current_dir()?;
exists.push("exists");
// Set up a directory for the broken symlink...
let mut bins = env::current_dir()?;
bins.push("bins");
fs::create_dir(&bins)?;
// ...and create the symlink.
let mut exe_path = bins.clone();
exe_path.push("exe_exists.exe");
symlink_file("DOES NOT EXIST", &exe_path)?;
// Set up the `PATH` environment variable with our paths.
let paths = env::join_paths(&[&bins, &exists]).unwrap();
env::set_var("PATH", paths);
// Try to run the file. It will try the broken symlink first.
let result = Command::new("exe_exists.exe").spawn();
println!("{:?}", result);
// Cleanup
fs::remove_dir_all(&bins)?;
Ok(())
}
The result of compiling and running this program:
Z:\test> rustc +stable run_symlink.rs
Z:\test> ./run_symlink
Err(Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." })
Z:\test> rustc +nightly run_symlink.rs
Z:\test> ./run_symlink
Ok(Child { stdin: None, stdout: None, stderr: None, .. })