Description
Many users want to turn relative paths into absolute paths, but the only tool that libstd currently offers is canonicalize
which is bad because it has to hit the filesystem which has several downsides:
- It takes time to hit the filesystem.
- The path has to actually exist.
- It fails on certain types of drives such as RAM drives on Windows.
- The path it creates is a
\\?\
path which not all software can handle correctly and imposes requirements on further path manipulation that few users are even aware of.
Needing symbolic links actually resolved is an extremely rare use case, and is often misused to compare paths for equality when in reality you should be comparing file IDs due to things like hard links existing.
A new function (normalize
or make_absolute
or something, bikeshed away) should be added that will turn a relative path into an absolute path without touching the filesystem. On Windows this should either call GetFullPathNameW
or do the pure Rust equivalent while on unixy platforms... something should happen, I have no idea.
If such a function did exist, rustc could start using that instead of canonicalize which would fix a whole host of issues including:
#74327
#74146
#59107
#58613
#55812
#52440
#48249
#45067
#42869
Activity