Skip to content

fix(desktop): capture login-shell PATH on direct Unix GUI launches - #6912

Merged
Astro-Han merged 2 commits into
rust-previewfrom
fix/desktop-login-shell-path
Nov 14, 2026
Merged

Astro-Han merged 2 commits into
rust-previewfrom
fix/desktop-login-shell-path

Conversation

@Astro-Han

Copy link
Copy Markdown
Contributor

Summary

When Maka.app or maka-desktop-shell is opened directly from Finder, the Dock, Spotlight or a Linux desktop launcher, it inherits only the desktop session's minimal PATH (for example /usr/bin:/bin:/usr/sbin:/sbin under macOS LaunchServices). The Host spawned by maka desktop inherits that stripped PATH, so external agent CLIs (agy, codex, claude) and MCP servers installed in ~/.local/bin or Homebrew report as not installed.

Before maka-desktop-shell's direct-launch bootstrap spawns maka desktop on Unix, capture PATH from the user's interactive login shell when neither TERM nor COLORTERM is set (and MAKA_SKIP_SHELL_ENV is not 1), then pass that PATH to maka desktop so both the Host and subsequent Host reconnections inherit it:

  • Keeping resolution inside maka-desktop-shell's direct-open bootstrap leaves CLI invocations and env_clear() integration test sandboxes untouched.
  • Importing only PATH prevents shell startup files from injecting application-control environment variables, and shell stderr is sent to /dev/null so startup secrets are never retained or logged.
  • Executing /bin/sh inside the login shell ensures shells where $PATH is a list (fish, nu, csh/tcsh) export a standard colon-delimited PATH before printing it between per-run UUID markers.
  • Running the probe in its own setsid() session/process group prevents interactive TTY stop signals and ensures startup-file background descendants are terminated on completion, failure, output overflow (64 KiB) or timeout (5s), falling back to the inherited PATH on error.

Verification

  • Ran cargo nextest run -p maka-desktop-shell --locked (unit tests and open_directly integration tests covering login-shell PATH import, non-leakage of other shell variables, background descendant cleanup, TERM/COLORTERM/MAKA_SKIP_SHELL_ENV=1 skip paths, non-zero exit fallback and output-flood bounding; verified new tests fail before the change and pass with it).
  • Ran cargo clippy -p maka-desktop-shell --all-targets --no-deps -- -D warnings, just fmt-check, just licenses, node scripts/rust/dependencies.mjs generate and node scripts/rust/notices.mjs generate.
  • Exercised Maka.app/Contents/MacOS/maka-desktop-shell under a stripped LaunchServices-equivalent environment (PATH=/usr/bin:/bin:/usr/sbin:/sbin, no TERM/COLORTERM, real /bin/zsh with noisy .zshrc banner) and confirmed the spawned maka launcher resolved /Users/yuhan/.local/bin/agy, /Users/yuhan/.local/bin/codex and /opt/homebrew/bin/claude.
  • Did not run Linux GTK desktop tests or unrelated workspace crates locally; left to CI.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Antigravity diagnosed the LaunchServices PATH root cause, implemented products/maka/desktop-shell/src/login_path.rs, updated main.rs, tests and desktop-shell READMEs, and ran local verification.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Opening Maka.app or maka-desktop-shell from Finder, the Dock, Spotlight or a Linux desktop launcher gives the process a minimal system PATH (such as /usr/bin:/bin:/usr/sbin:/sbin), hiding user-installed CLIs like agy, codex and claude in ~/.local/bin or Homebrew from the Host.

Resolve PATH from the user's interactive login shell inside maka-desktop-shell's direct-open bootstrap before spawning maka desktop, when neither TERM nor COLORTERM is set and MAKA_SKIP_SHELL_ENV is not 1. Keep CLI invocations and isolated test sandboxes untouched, import only PATH so startup scripts cannot inject control variables, execute /bin/sh inside the login shell so non-POSIX shells export a colon-delimited PATH, bound output and runtime, and kill the dedicated probe process group on completion or failure.

Generated-by: Antigravity
Pass a leading-hyphen argv[0] when probing csh/tcsh so ~/.login is sourced alongside ~/.cshrc, and return as soon as the paired UUID markers arrive instead of polling child exit for up to 100ms.

Generated-by: Antigravity
@Astro-Han
Astro-Han marked this pull request as ready for review November 14, 2026 16:06
@Astro-Han
Astro-Han merged commit c1da07b into rust-preview Nov 14, 2026
2 checks passed
@Astro-Han
Astro-Han deleted the fix/desktop-login-shell-path branch November 14, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant