From ab8907e7350081aec58db6ebb39ce58607adee29 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 1 Dec 2021 08:42:02 -0700 Subject: [PATCH] env: put appimage bin dir into path This allows `wezterm connect unix` to work for me when using the appimage. refs: https://github.com/wez/wezterm/issues/1359 --- env-bootstrap/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/env-bootstrap/src/lib.rs b/env-bootstrap/src/lib.rs index 9ef31fb54..745e6f625 100644 --- a/env-bootstrap/src/lib.rs +++ b/env-bootstrap/src/lib.rs @@ -23,6 +23,19 @@ pub fn fixup_appimage() { // Let's just unset that from the environment! std::env::remove_var("ARGV0"); + // Since our AppImage includes multiple utilities, we want to + // be able to use them, so add that location to the PATH! + // WEZTERM_EXECUTABLE_DIR is set by `set_wezterm_executable` + // which is called before `fixup_appimage` + if let Some(dir) = std::env::var_os("WEZTERM_EXECUTABLE_DIR") { + if let Some(path) = std::env::var_os("PATH") { + let mut paths = std::env::split_paths(&path).collect::>(); + paths.insert(0, PathBuf::from(dir)); + let new_path = std::env::join_paths(paths).expect("unable to update PATH"); + std::env::set_var("PATH", &new_path); + } + } + // This AppImage feature allows redirecting HOME and XDG_CONFIG_HOME // to live alongside the executable for portable use: // https://github.com/AppImage/AppImageKit/issues/368