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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Tool and `PATH` resolution for every Subspace app.
//!
//! A desktop app started from Finder, the Dock, a desktop entry or the Start
//! Menu does not inherit the `PATH` a terminal has. On macOS launchd gives it
//! `/usr/bin:/bin:/usr/sbin:/sbin`, so Azure CLI from Homebrew
//! (`/opt/homebrew/bin/az`) is not found. The host calls [`apply`] once at
//! startup, before any thread exists. It asks the user's login shell (on
//! Windows, the registry) for the `PATH` a terminal has and merges it with the
//! inherited one. When the shell fails, it adds the `PATH` that worked last
//! time ([`PathCache`]) and then the usual install folders of the platform
//! ([`FALLBACK_DIRECTORIES`]). Child processes inherit the result.
//!
//! The same login shell also supplies the proxy and certificate variables
//! ([`network`]) that this process lacks. They are never written to the cache.
//!
//! Every lookup of an external program uses [`find_tool`]: `PATH` first, then
//! the path where the tool was found last time. Do not add other `PATH`
//! lookups.
use ;
use Duration;
pub use ;
pub use Capture;
pub use ;
pub use ;
pub use ;
/// Set to `0` to keep the inherited `PATH`.
pub const DISABLE_ENV: &str = "SUBSPACE_GUI_LOGIN_PATH";
/// The short name of [`DISABLE_ENV`]; either one set to `0` works.
pub const DISABLE_ENV_ALIAS: &str = "SUBSPACE_LOGIN_PATH";
/// How long the login shell may take to start and print its environment
/// when no saved `PATH` exists. This is the worst-case delay of a start: a
/// fast shell returns at the end marker, so only a slow or stuck shell waits
/// this long. Startup files that load nvm or endpoint-security agents can
/// take several seconds just after the computer starts. There is one
/// attempt, never a second one.
pub const SHELL_TIMEOUT: Duration = from_secs;
/// The shorter limit when a saved `PATH` can stand in for a slow shell.
pub const CACHED_SHELL_TIMEOUT: Duration = from_secs;
/// The login-shell time limit: shorter when a saved `PATH` exists.
/// The cache file name, beside the product's `state.json`.
pub const CACHE_FILE: &str = "path-cache.json";
/// `<state dir>/path-cache.json`.
/// The markers around the `env` output of the login shell (Unix only).
pub const START: &str = "__SUBSPACE_PATH_START__";
pub const END: &str = "__SUBSPACE_PATH_END__";