Simplify environment loading code (#40531)

This is a refactoring PR to simplify our environment loading code by:

- Getting rid of `EnvironmentErrorMessage` in favor of using
`anyhow::Result` everywhere, with a separate `mpsc` channel to
communicate statuses that will be shown in the activity indicator
- Inlining some functions that were only called once to reduce
indirection
- Removing the separate `direnv` module

Release Notes:

- N/A
This commit is contained in:
Cole Miller
2025-10-23 03:57:33 +00:00
committed by GitHub
parent bf63ff2b91
commit 18daa9a839
6 changed files with 144 additions and 248 deletions
+5 -2
View File
@@ -353,7 +353,10 @@ pub async fn load_login_shell_environment() -> Result<()> {
// into shell's `cd` command (and hooks) to manipulate env.
// We do this so that we get the env a user would have when spawning a shell
// in home directory.
for (name, value) in shell_env::capture(get_system_shell(), &[], paths::home_dir()).await? {
for (name, value) in shell_env::capture(get_system_shell(), &[], paths::home_dir())
.await
.with_context(|| format!("capturing environment with {:?}", get_system_shell()))?
{
unsafe { env::set_var(&name, &value) };
}
@@ -627,7 +630,7 @@ where
}
pub fn log_err<E: std::fmt::Debug>(error: &E) {
log_error_with_caller(*Location::caller(), error, log::Level::Warn);
log_error_with_caller(*Location::caller(), error, log::Level::Error);
}
pub trait TryFutureExt {