-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Unknown problem opening <local actual file>" on Electron (#3220)
* add electron logging to main browser process console * add logging * removing old way * release notes * adding some logs in to test mac build * repent satan * i caste yeee oooott sinner * derp * hmmm< * forcing nodegyprebuild * not like this.... Not like this... 😢 * hmm * dunno * will it recognise it if i link it manually.. 👀 * give up * rebuild * merge asars fasle * update package * manually do it ffs work damnit * remove the cmd * dont rebuild cause i build it manually * dafuq is this, two bettersqlite modules installed huhhhhh * test * does this work? * bloody hell * couple more logs * test this out * arch in name * adding the rebuild step back into first build * try rebuild before pack - so we know what arch we need * having a laugh * tidying up * release notes * move package up a bit * exit process if no electron verison
- Loading branch information
1 parent
43ff1c0
commit 6f3af7b
Showing
4 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { rebuild } from '@electron/rebuild'; | ||
import { Arch, AfterPackContext } from 'electron-builder'; | ||
|
||
/* The beforePackHook runs before packing the Electron app for an architecture | ||
We hook in here to build anything architecture dependent - such as beter-sqlite3 | ||
To build, we call @electron/rebuild on the better-sqlite3 module */ | ||
const beforePackHook = async (context: AfterPackContext) => { | ||
const arch: string = Arch[context.arch]; | ||
const buildPath = context.packager.projectDir; | ||
const projectRootPath = buildPath + '/../../'; | ||
const electronVersion = context.packager.config.electronVersion; | ||
|
||
if (!electronVersion) { | ||
console.error('beforePackHook: Unable to find electron version.'); | ||
process.exit(); // End the process - electron version is required | ||
} | ||
|
||
try { | ||
await rebuild({ | ||
arch, | ||
buildPath, | ||
electronVersion, | ||
force: true, | ||
projectRootPath, | ||
onlyModules: ['better-sqlite3'], | ||
}); | ||
|
||
console.info(`Rebuilt better-sqlite3 with ${arch}!`); | ||
} catch (err) { | ||
console.error('beforePackHook:', err); | ||
process.exit(); // End the process - unsuccessful build | ||
} | ||
}; | ||
|
||
// eslint-disable-next-line import/no-unused-modules, import/no-default-export | ||
export default beforePackHook; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
category: Bugfix | ||
authors: [MikesGlitch] | ||
--- | ||
|
||
Fix electron builds throwing "We had an unknown problem opening file" | ||
|