Skip to content

Commit b6c944c

Browse files
thelonewander3rjuliusmarminge
authored andcommitted
fix(desktop): carry login-shell Android SDK selection
1 parent 843f4e3 commit b6c944c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export class DesktopShellEnvironment extends Context.Service<
7575

7676
const LOGIN_SHELL_ENV_NAMES = [
7777
"PATH",
78+
"ANDROID_HOME",
79+
"ANDROID_SDK_ROOT",
7880
"DBUS_SESSION_BUS_ADDRESS",
7981
"DISPLAY",
8082
"LANG",
@@ -99,6 +101,7 @@ const LOGIN_SHELL_ENV_NAMES = [
99101
] as const;
100102
const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;
101103
const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;
104+
const ANDROID_SDK_ENV_NAMES = ["ANDROID_HOME", "ANDROID_SDK_ROOT"] as const;
102105
const FALLBACK_LC_CTYPE = "en_US.UTF-8";
103106
const WINDOWS_SHELL_CANDIDATES = ["pwsh.exe", "powershell.exe"] as const;
104107
const LOGIN_SHELL_TIMEOUT = Duration.seconds(5);
@@ -465,6 +468,17 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
465468
}
466469
}
467470

471+
// The device host picks the Android SDK from ANDROID_HOME before ANDROID_SDK_ROOT,
472+
// so a profile-only ANDROID_HOME must not shadow an inherited ANDROID_SDK_ROOT.
473+
if (ANDROID_SDK_ENV_NAMES.every((name) => Option.isNone(trimNonEmpty(config.env[name])))) {
474+
for (const name of ANDROID_SDK_ENV_NAMES) {
475+
const value = trimNonEmpty(shellEnvironment[name]);
476+
if (Option.isSome(value)) {
477+
config.env[name] = value.value;
478+
}
479+
}
480+
}
481+
468482
// Locale variables form one precedence group: LC_ALL can override an inherited
469483
// LANG or LC_CTYPE, so only hydrate the group when the process has none of them.
470484
if (

0 commit comments

Comments
 (0)