mirror of
https://github.com/electron/electron.git
synced 2026-10-28 11:44:46 +08:00
fix: load the zip extractor only when extraction runs (#52748)
The module-level require of @electron-internal/extract-zip runs before isInstalled() and before ELECTRON_OVERRIDE_DIST_PATH is read. When an OS policy blocks the dlopen of the bundled native binding, install.js dies on line 5 and no short-circuit can help (#52481). Move the require into extractFile(). An installed dist now passes isInstalled() without loading the extractor, and the environment overrides work again.
This commit is contained in:
1 parent
cc6926e91b
commit
51e0d451e3
1 file changed
+6
-2
+6
-2
@@ -2,8 +2,6 @@
|
||||
|
||||
const { downloadArtifact } = require('@electron/get');
|
||||
|
||||
const { extract } = require('@electron-internal/extract-zip');
|
||||
|
||||
const childProcess = require('child_process');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
@@ -77,6 +75,12 @@ function isInstalled() {
|
||||
|
||||
// unzips and makes path.txt point at the correct executable
|
||||
function extractFile(zipPath) {
|
||||
// Loaded here, not at the top of the file: the extractor has a native
|
||||
// binding, and an OS policy can block its load (see electron/electron#52481).
|
||||
// A lazy require keeps `isInstalled()` working in that case, so an
|
||||
// already-installed dist does not need the extractor at all.
|
||||
const { extract } = require('@electron-internal/extract-zip');
|
||||
|
||||
const distPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist');
|
||||
|
||||
return extract(zipPath, { dir: path.join(__dirname, 'dist') }).then(() => {
|
||||
|
||||
Reference in new issue
Block a user