1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Minimal `home_dir()` shim. We keep this in-tree to avoid pulling in
//! the `dirs` crate just for one lookup.
//!
//! Lookup order:
//! - Unix: `$HOME` (every login shell sets this).
//! - Windows: `%USERPROFILE%` first, falling back to `%HOME%` (some
//! MSYS / Git Bash setups export `HOME` instead of `USERPROFILE`,
//! so honoring both keeps `cargo truce` working in both shells
//! without a `dirs` dependency).
//!
//! Returns `None` only when no usable env var is set; callers that
//! need a hard requirement (e.g. CLAP user-scope install) should
//! propagate the `None` as an error instead of `unwrap()`-ing.
use PathBuf;
/// Hard-required form of [`home_dir`]. Returns a typed error so the
/// surrounding command can print one line ("can't determine home
/// directory: set HOME / USERPROFILE") instead of panicking on the
/// `Option::unwrap` the audit flagged across `cmd_status`,
/// `cmd_remove`, install paths, and `cmd_reset_au`.
//
// Gated to macOS: every caller (`cmd_status`, `cmd_reset_au` macOS impl)
// is itself macOS-gated, so on Linux/Windows this would be dead code.
pub