Background: When Gram is launched from Finder or Spotlight (no PTY attached), load_login_shell_environment() captures the user's login shell environment and sets every variable it finds, unconditionally overwriting the current environment. This is probably the correct approach for most variables, but PATH should be treated differently...
Issue: In my Nix configuration, I want to wrap the Gram binary with a script that prepends PATH with locations of additional tools (e.g., language servers). Those injected paths aren't in my global profile, so Gram discards/overwrites them.
This is a known issue for Zed as well, affecting Home Manager users (see: nix-community/home-manager#7112).
Fix: Save the current process PATH (original) before the login shell PATH (new) is captured. Then prepend any entries present in the original but not in the new PATH (avoiding duplication).
In summary:
- Terminal launch (PTY detected): no change;
load_login_shell_environment is skipped.
- Finder/Spotlight launch (no PTY): wrapper-injected
PATH entries survive the capture, and are prepended to the login shell's PATH.
**Background:** When Gram is launched from Finder or Spotlight (no PTY attached), `load_login_shell_environment()` captures the user's **login shell** environment and sets every variable it finds, unconditionally overwriting the current environment. This is probably the correct approach for most variables, but `PATH` should be treated differently...
**Issue:** In my Nix configuration, I want to wrap the Gram binary with a script that prepends `PATH` with locations of additional tools (e.g., language servers). Those injected paths aren't in my global profile, so Gram discards/overwrites them.
This is a known issue for Zed as well, affecting Home Manager users (see: [nix-community/home-manager#7112](https://github.com/nix-community/home-manager/issues/7112)).
**Fix:** Save the current process `PATH` (original) before the login shell `PATH` (new) is captured. Then prepend any entries present in the original but not in the new `PATH` (avoiding duplication).
In summary:
- Terminal launch (PTY detected): no change; `load_login_shell_environment` is skipped.
- Finder/Spotlight launch (no PTY): wrapper-injected `PATH` entries survive the capture, and are prepended to the login shell's `PATH`.