feat(app): LoginShell PATH repair and dependency-free include_identity!#10
Closed
BumpyClock wants to merge 2 commits into
Closed
feat(app): LoginShell PATH repair and dependency-free include_identity!#10BumpyClock wants to merge 2 commits into
BumpyClock wants to merge 2 commits into
Conversation
GUI-launched apps on macOS and Linux inherit a minimal PATH that omits login-shell entries (Homebrew, version-manager shims), so tools the app shells out to cannot be found. Wire EnvironmentPolicy::LoginShell to the fix-path-env crate (Tauri's login-shell repair, Apache-2.0 OR MIT) and apply it in Preflight before anything is spawned. The repair mutates the process environment via std::env::set_var, which is UB on Unix under concurrent env access. The variant's rustdoc makes the precondition the caller's explicit obligation: select it only from a single-threaded main() before any thread spawns. This is the same objection that keeps a Custom(vars) variant out of the enum; it is accepted here only because the repair is a single vetted operation, not an open-ended env hook. A failed repair is logged and falls back to the inherited environment, never aborting startup. fix-path-env is pulled in only on macOS/Linux; Windows GUI processes inherit PATH correctly, so the policy is a documented no-op there.
The build.rs-generated identity source hardcoded the absolute path ::gpui_component_manifest::schema::IdentityRef, forcing every consuming app to carry gpui-component-manifest as a runtime dependency (plus a cargo-machete ignore) even when it only reached the macro through gpui-component-app's re-export. Emit the schema types unqualified and have include_identity! expand to a private module that imports them with `use $crate::schema::*` before include!()-ing the generated file. $crate resolves to the defining crate by def-id, so it works transitively through a re-export: an app calling gpui_component_app::include_identity!() now needs the manifest crate only as a build-dependency. Drop the direct runtime dep and machete ignore from both example apps, and switch the downstream fixture to reach the macro through a local re-export shim so it proves the dependency-free path in a hermetic test.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two follow-ups on the AppShell platform stack. Stacks on #8 (base:
feat/app-platform, notmain); review/merge #8 first.1. Real
EnvironmentPolicy::LoginShell(tsq-5)LoginShellpreviously logged a warning and behaved asInherit. It now performs the macOS/Linux GUI-launch PATH repair that agent-term needs before it can migrate.Preflightvia thefix-path-envcrate (Tauri's login-shell PATH fixer,Apache-2.0 OR MIT, the same crate + rev agent-term already uses). Pulled in only on macOS/Linux; Windows is a documented no-op (GUI processes inherit PATH from the launching context).std::env::set_var, which is UB on Unix under concurrent env access. The variant's rustdoc places the obligation on the caller: selectLoginShellonly from a single-threadedmain()before any thread spawns. This mirrors why the deletedCustom(vars)variant was rejected — accepted here only because it's a single vetted repair, not an open-ended env hook. The no-Customcomment block is updated to reference it.Inherit, never a startup abort.Inherit, setter recordsLoginShell,Inheritis a no-op); actual PATH mutation is not asserted in CI.2.
include_identity!needs no direct manifest dependency (tsq-6)The generated identity source hardcoded
::gpui_component_manifest::schema::IdentityRef, an absolute path that forced every consuming app onto a runtime dependency ongpui-component-manifest(plus acargo-macheteignore) even when it reached the macro throughgpui-component-app's re-export.include_identity!expands to a private module that imports them withuse $crate::schema::{…}beforeinclude!()-ing the file.$crateresolves to the defining crate by def-id, so it works transitively through a re-export.gpui_component_app::include_identity!()now needgpui-component-manifestonly as a[build-dependencies]entry (foremit_identity()inbuild.rs).Gates
cargo test -p gpui-component-manifest -p gpui-component-app— pass (incl. downstream fixture + new env/macro tests)app_shell+app_shell_traybuild and--smokeexit 0cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --check— cleanNote:
cargo machetereports two dependencies (gpui-component-assetsincrates/app,smolinexamples/system_monitor) — both pre-existing onfeat/app-platform, untouched here. This PR introduces no new machete findings.