Description
As of now, the stable and nightly documentation on std::env::current_dir
only states
Returns the current working directory as a PathBuf.
And proceeds to note a couple of errors the function may fail with.
This does not mention the fact that (as far as I am aware, testing on Linux) the path is also canonicalized, having resolved all symlinks in any segment of the path. I'd imagine not documenting this behavior could lead to confusion and/or bugs, if it already hasn't.
I tried this code within a symlink folder /example/symlink/here
pointing to /symlink/target/here
:
println!("{:#?}",std::env::current_dir().unwrap())
I expected to see get the output: "/example/symlink/here"
Instead, this was output: "/symlink/target/here"
Currently using the nightly compiler.
For obvious reasons, there's no backtrace.
Update: Read a bit through the code and realized this behavior might be libc-dependent
ldd --version
on my system returns ldd (GNU libc) 2.33