Description
Hi, I hope this is the right forum/format to register this problem, let me know if it's not.
Today I tried to use std::fs::canonicalize
to make a path absolute so that I could execute it with std::process::Command
. canonicalize
returns so-called "UNC paths", which look like this: \\?\C:\foo\bar\...
(sometimes the ?
can be a hostname).
It turns out you can't pass a UNC path as the current directory when starting a process (i.e., Command::new(...).current_dir(unc_path)
). In fact, a lot of other apps will blow up if you pass them a UNC path: for example, Microsoft's own cl.exe
compiler doesn't support it: rust-lang/cc-rs#169
It feels to me that maybe returning UNC paths from canonicalize is the wrong choice, given that they don't work in so many places. It'd probably be better to return a simple "absolute path", which begins with the drive letter, instead of returning a UNC path, and instead provide a separate function specifically for generating UNC paths for people who need them.
Maybe if this is too much of an incompatible change, a new function for creating absolute paths should be added to std? I'd bet, however, that making the change to canonicalize
itself would suddenly make more software suddenly start working rather than suddenly break.