From e235c3fff08af3ad72a971fcbfed28fbaa18bbd0 Mon Sep 17 00:00:00 2001 From: Asish Kumar <87874775+officialasishkumar@users.noreply.github.com> Date: Tue, 28 Apr 2026 21:37:05 +0530 Subject: [PATCH] fix: honor `ELECTRON_INSTALL_PLATFORM` in `getPlatformPath` (#51029) The postinstall script resolves two things from the target platform: 1. Which artifact to download, via `downloadArtifact({ platform, ... })`. Since #49981, `platform` is derived from `ELECTRON_INSTALL_PLATFORM || npm_config_platform || process.platform`. 2. Which executable path to use for the `isInstalled()` cache check and for the `path.txt` marker written after extraction, via `getPlatformPath()`. `getPlatformPath()` was not updated with the rest of that change and still falls back to `npm_config_platform || os.platform()` only. As a result, passing `ELECTRON_INSTALL_PLATFORM` (as documented in `docs/tutorial/installation.md`) causes the two to disagree: the download fetches the requested platform's zip, but `path.txt` and the path sanity check are written against the host platform's executable name. That in turn makes `isInstalled()` always return `false` on subsequent runs (forcing redundant re-downloads) and makes the executable path recorded in `path.txt` wrong for the artifact that was actually extracted (e.g. `electron` written alongside a `darwin`/`win32` build). Check `ELECTRON_INSTALL_PLATFORM` first, matching the resolution used for `downloadArtifact`. Signed-off-by: Asish Kumar --- npm/install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/install.js b/npm/install.js index efd140768b..540e1e68a5 100755 --- a/npm/install.js +++ b/npm/install.js @@ -96,7 +96,7 @@ function extractFile(zipPath) { } function getPlatformPath() { - const platform = process.env.npm_config_platform || os.platform(); + const platform = process.env.ELECTRON_INSTALL_PLATFORM || process.env.npm_config_platform || os.platform(); switch (platform) { case 'mas':