Skip to content

fix: make ELECTRON_OVERRIDE_DIST_PATH work on macOS and Windows - #55403

Merged
MarshallOfSound merged 1 commit into
electron:mainfrom
rezacr588:fix/override-dist-path-default-executable
Nov 10, 2026
Merged

MarshallOfSound merged 1 commit into
electron:mainfrom
rezacr588:fix/override-dist-path-default-executable

Conversation

@rezacr588

Copy link
Copy Markdown
Contributor

Description of Change

npm/index.js joins ELECTRON_OVERRIDE_DIST_PATH with the executable path listed in path.txt, and falls back to a bare electron when there is no path.txt. That fallback came with #25377, for installs that skip scripts, and it is only the right file name on Linux: the executable is Electron.app/Contents/MacOS/Electron on macOS and electron.exe on Windows.

Since #49328 removed the postinstall script, path.txt doesn't exist until the binary is first downloaded. A fresh install with the override set therefore always hits the fallback, and because the override returns before any download, nothing ever writes path.txt either. require('electron') and the electron command end up pointing at a file that doesn't exist.

This falls back to the executable path of the current platform instead. An existing path.txt still takes precedence, as before. The fallback uses process.platform rather than ELECTRON_INSTALL_PLATFORM / npm_config_platform, which install.js honors when choosing what to download, because the override is a build that runs on this machine.

On macOS (arm64), with a fresh [email protected] install that hasn't downloaded anything, and ELECTRON_OVERRIDE_DIST_PATH pointing at an extracted Electron 45.0.0 distribution:

electron --version
before Error: spawn …/electron ENOENT
after v45.0.0

I added spec/npm-package.spec.ts, which covers how npm/index.js resolves the executable path: with the override and no path.txt, with the override and a path.txt, and without the override. I ran it with node script/spec-runner.js --electronVersion=45.0.0 --skipYarnInstall --files spec/npm-package.spec.ts on macOS (arm64). It passes with this change, and without it the override test fails (expected …/Electron.app/Contents/MacOS/Electron, received …/electron) while the other two pass. I haven't run the full suite, and the spec hasn't run on Windows or Linux yet.

I kept the platform mapping inside index.js instead of sharing the one in install.js through a new file, because I can't see how the files in npm/ are assembled for publishing. A shared module would avoid the duplicated switch, if a new file is safe to add. I didn't find an existing issue for this. It relates to #49900, but it doesn't add tests for the download itself.

This change was prepared with Claude Code (Claude Sonnet 5.5), as noted in the Co-Authored-By trailer.

🤖 Generated with Claude Code

Checklist

Release Notes

Notes: Fixed ELECTRON_OVERRIDE_DIST_PATH not working on macOS and Windows.

npm/index.js joins ELECTRON_OVERRIDE_DIST_PATH with the executable path
listed in path.txt, and falls back to a bare "electron" when there is no
path.txt (added in electron#25377 for installs that skip scripts). That is only
the right file name on Linux. The executable is
Electron.app/Contents/MacOS/Electron on macOS and electron.exe on
Windows.

Since electron#49328 removed the postinstall script, path.txt does not exist until
the binary is first downloaded, so a fresh install with the override set
always hits that fallback. The override also skips the download, so
require('electron') and the electron command kept pointing at a file that
does not exist.

Fall back to the executable path of the current platform instead, and add
a spec for how npm/index.js resolves the executable path.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@rezacr588
rezacr588 requested a review from a team as a code owner October 27, 2026 17:37
@welcome

welcome Bot commented Oct 27, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes no-backport labels Oct 29, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) October 29, 2026 07:55
@MarshallOfSound
MarshallOfSound merged commit 4c7369f into electron:main Nov 10, 2026
85 checks passed
@release-clerk

release-clerk Bot commented Nov 10, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed ELECTRON_OVERRIDE_DIST_PATH not working on macOS and Windows.

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

Labels

47-x-y no-backport semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants