Skip to content

Commit 37e4804

Browse files
Emanuel Lclaude
authored andcommitted
fix(desktop): carry ANDROID_HOME through from the login shell
A GUI launch inherits no shell rc, so `ANDROID_HOME` and `ANDROID_SDK_ROOT` exported from a profile never reach the app. The device host falls back to the default SDK locations, and when the SDK lives anywhere else it reports "Android SDK was not found. Install it with Android Studio or set ANDROID_HOME to your SDK directory" — to a user who has already done exactly that. Add both names to the POSIX login-shell hydration, alongside the existing HOMEBREW_* and XDG_* entries. Windows reads user variables from the registry and already inherits them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 20363c3 commit 37e4804

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎apps/desktop/src/shell/DesktopShellEnvironment.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ describe("DesktopShellEnvironment", () => {
129129
}),
130130
);
131131

132+
it.effect("hydrates the Android SDK location from the login shell on macOS", () =>
133+
Effect.gen(function* () {
134+
const env: NodeJS.ProcessEnv = { SHELL: "/bin/zsh", PATH: "/usr/bin" };
135+
136+
yield* runShellEnvironment({
137+
env,
138+
platform: "darwin",
139+
handler: () =>
140+
envOutput({
141+
PATH: "/usr/bin",
142+
ANDROID_HOME: "/Volumes/Work/android-sdk",
143+
ANDROID_SDK_ROOT: "/Volumes/Work/android-sdk",
144+
}),
145+
});
146+
147+
assert.equal(env.ANDROID_HOME, "/Volumes/Work/android-sdk");
148+
assert.equal(env.ANDROID_SDK_ROOT, "/Volumes/Work/android-sdk");
149+
}),
150+
);
151+
132152
it.effect("preserves inherited POSIX values when present", () =>
133153
Effect.gen(function* () {
134154
const env: NodeJS.ProcessEnv = {

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ export class DesktopShellEnvironment extends Context.Service<
6969

7070
const LOGIN_SHELL_ENV_NAMES = [
7171
"PATH",
72+
// A GUI launch runs no shell rc, so an SDK in a non-default location is
73+
// invisible to the device host, which then tells the user to "set
74+
// ANDROID_HOME" — advice they have usually already followed in their profile.
75+
"ANDROID_HOME",
76+
"ANDROID_SDK_ROOT",
7277
"DBUS_SESSION_BUS_ADDRESS",
7378
"DISPLAY",
7479
"LANG",
@@ -466,6 +471,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
466471
}
467472

468473
for (const name of [
474+
"ANDROID_HOME",
475+
"ANDROID_SDK_ROOT",
469476
"DISPLAY",
470477
"HOMEBREW_PREFIX",
471478
"HOMEBREW_CELLAR",

0 commit comments

Comments
 (0)