From c6bc8c6c280e704c16d890a7fc310b6803af85a4 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 18 Dec 2023 14:33:36 -0800 Subject: [PATCH] https://www.update.rocks/blog/fixing-the-python3/ If you are using electron-packager or electron-forge, you might encounter the following error : An unhandled rejection has occurred inside Forge: Error: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/electron-packager/darwin-x64/electron-example-darwin-x64-5AYzr2/Electron.app/Contents/Resources/app/node_modules/macos-alias/build/node_gyp_bins/python3: file "../../../../../../../../../../../../../Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11" links out of the package This error is showing when trying to package an electron application for macOS with Electron Forge. It takes its root in electron-packager and is produced by node-gyp like described in this Github issue. https://github.com/nodejs/node-gyp/issues/2713 --- forge.config.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/forge.config.js b/forge.config.js index 4f3e11dfb..276d2f73d 100644 --- a/forge.config.js +++ b/forge.config.js @@ -143,6 +143,12 @@ let config = { return packageJson; }, packageAfterPrune: async (forgeConfig, buildPath, electronVersion, platform, arch) => { + if (platform === 'darwin') { + console.log("We need to remove the problematic link file on macOS") + console.log(`Build path ${buildPath}`) + fs.unlinkSync(path.join(buildPath, 'node_modules/macos-alias/build/node_gyp_bins/python3')) + }, + const npmInstall = spawnSync("npm", ["install", "--omit=dev"], { cwd: buildPath, stdio: "inherit",