Skip to content

fix: honor ELECTRON_INSTALL_PLATFORM in getPlatformPath (#51029)#51370

Merged
jkleinsc merged 4 commits into
electron:42-x-yfrom
erickzhao:bp/install-platform
May 5, 2026
Merged

fix: honor ELECTRON_INSTALL_PLATFORM in getPlatformPath (#51029)#51370
jkleinsc merged 4 commits into
electron:42-x-yfrom
erickzhao:bp/install-platform

Conversation

@erickzhao

Copy link
Copy Markdown
Member

Backport of #51029

See that PR for details.

Notes: Fixed ELECTRON_INSTALL_PLATFORM being ignored when resolving the Electron executable path during postinstall, which caused path.txt to be written for the host platform instead of the requested target and made isInstalled() always re-download on subsequent installs.

@erickzhao erickzhao requested a review from a team as a code owner April 28, 2026 16:51
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Apr 28, 2026
@trop trop Bot added 42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Apr 28, 2026
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Apr 28, 2026
…#51029)

The postinstall script resolves two things from the target platform:

1. Which artifact to download, via `downloadArtifact({ platform, ... })`.
   Since electron#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 <officialasishkumar@gmail.com>
@ckerr ckerr force-pushed the bp/install-platform branch from e1b5141 to 14310cb Compare April 30, 2026 03:04
@jkleinsc

jkleinsc commented May 5, 2026

Copy link
Copy Markdown
Member

Merging as CI failure unrelated to PR change.

@jkleinsc jkleinsc merged commit 2a4e369 into electron:42-x-y May 5, 2026
59 of 62 checks passed
@release-clerk

release-clerk Bot commented May 5, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed ELECTRON_INSTALL_PLATFORM being ignored when resolving the Electron executable path during postinstall, which caused path.txt to be written for the host platform instead of the requested target and made isInstalled() always re-download on subsequent installs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants