Skip to content

Commit 59fde0b

Browse files
authored
Rollup merge of rust-lang#101648 - Timmmm:home_dir_docs, r=joshtriplett
Better documentation for env::home_dir()'s broken behaviour This improves the documentation to say *why* it was deprecated. The reason was because it reads `HOME` on Windows which is meaningless there. Note that the PR that deprecated it stated that returning an empty string if `HOME` is set to an empty string was a problem, however I can find no evidence that this is the case. `cd` handles it fine whereas if `HOME` is unset it gives an explicit `HOME not set` error. * Original deprecation reason: https://internals.rust-lang.org/t/deprecate-or-break-fix-std-env-home-dir/7315 * Original deprecation PR: rust-lang#51656 See rust-lang#71684
2 parents d137783 + 8f0025e commit 59fde0b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

library/std/src/env.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ impl Error for JoinPathsError {
570570
///
571571
/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya
572572
///
573+
/// # Deprecation
574+
///
575+
/// This function is deprecated because the behaviour on Windows is not correct.
576+
/// The 'HOME' environment variable is not standard on Windows, and may not produce
577+
/// desired results; for instance, under Cygwin or Mingw it will return `/home/you`
578+
/// when it should return `C:\Users\you`.
579+
///
573580
/// # Examples
574581
///
575582
/// ```
@@ -582,7 +589,7 @@ impl Error for JoinPathsError {
582589
/// ```
583590
#[deprecated(
584591
since = "1.29.0",
585-
note = "This function's behavior is unexpected and probably not what you want. \
592+
note = "This function's behavior may be unexpected on Windows. \
586593
Consider using a crate from crates.io instead."
587594
)]
588595
#[must_use]

0 commit comments

Comments
 (0)