question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rebuilding native dependencies states one platform/arch, builds another

See original GitHub issue
  • Version: 22.4.1 (initially found bug) and 22.7.0 (bug still present on latest)
  • Electron Version: 7.3.0 (initially found bug) and 8.3.0 (upgraded to latest 8.x, v9.0.0 a few days old)
  • Electron Type (current, beta, nightly): NA
  • Target: Win:nsis
  • Node/NPM: Node=v12.16.1 NPM=6.13.4

Summary: During build process on container (Linux) for Windows target says it is rebuilding native dependencies for win32-x64, but upon running the application (after a error-less build) an error occurs saying linux-x64 binaries cannot be used on the win32-x64 platform.

Details:

I’ve run the following on electronuserland/builder:wine and electronuserland/builder:wine-mono images:

npm ci
npm run bundle:electron-renderer    # Webpack bundle for renderer process
npm run transpile                   # Babel to transpile code used by main process 
node ./scripts/pre-package.js && electron-builder build --win --publish never

With the following under build in package.json:

{
  "asar": true,
  "appId": "com.maestro.app",
  "productName": "Maestro",
  "directories": {
    "output": "electron-release"
  },
  "files": [
    "build/",
    "index.js",
    "bundle/renderer-entry.js",
    "node_modules/",
    "package.json"
  ],
  "extraFiles": [
    "build/icon.png",
    "build/icon.ico"
  ],
  "detectUpdateChannel": false,
  "publish": {
    "provider": "generic",
    "url": "https://example.com/maestro"
  },
  "win": {
    "target": "nsis",
    "verifyUpdateCodeSignature": false,
    "icon": "build/icon.ico"
  },
  "nsis": {
    "oneClick": false,
    "perMachine": false,
    "allowElevation": true,
    "allowToChangeInstallationDirectory": true
  }
}

The Windows installer builds without errors. However, after running the installer, I get the following error upon starting the application:

image

So there is an issue with getting the right binary for the “sharp” package. During the build process, it states that it is “rebuilding native dependencies” using win32 and x64, as shown below:

 > node ./scripts/pre-package.js && electron-builder build --win --publish never
   • electron-builder  version=22.4.1 os=3.10.0-1127.8.2.el7.x86_64
   • loaded configuration  file=package.json ("build" field)
   • electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies
 To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
   • rebuilding native dependencies  dependencies=sharp@0.25.3, fsevents@1.2.11 platform=win32 arch=x64
   • install prebuilt binary  name=sharp version=0.25.3 platform=win32 arch=x64
   • packaging       platform=win32 arch=x64 electron=7.3.0 appOutDir=electron-release/win-unpacked

I’ve also made the following two changes and gotten the same error message:

  1. Add this after npm ci: ./node_modules/.bin/electron-builder install-app-deps --platform win32 --arch x64
  2. Add "npmRebuild": false to package.json under build.

This appears to just remove the rebuild step from the electron-builder build step and instead makes it an earlier step. The output for this is:

 $ ./node_modules/.bin/electron-builder install-app-deps --platform win32 --arch x64
   • electron-builder  version=22.7.0
   • loaded configuration  file=package.json ("build" field)
   • rebuilding native dependencies  dependencies=sharp@0.25.3, fsevents@1.2.11 platform=win32 arch=x64
   • install prebuilt binary  name=sharp version=0.25.3 platform=win32 arch=x64

This has been performed on:

  • electron-builder@22.4.1 with electron@7.3.0 on electronuserland/builder:wine
  • electron-builder@22.7.0 with electron@7.3.0 on electronuserland/builder:wine
  • electron-builder@22.7.0 with electron@8.3.0 on electronuserland/builder:wine
  • electron-builder@22.7.0 with electron@8.3.0 on electronuserland/builder:wine-mono

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
anonrigcommented, Apr 5, 2022

We’re having a similar issue. I believe this issue needs to be reopened.

1reaction
deathlyragecommented, Oct 20, 2020

Please reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron cannot build platform dependencies fsevents and/or ...
I want to distribute my web-app to OS X using electron . During adaptation it for electron extra dependencies of sqlite3 and fsevents...
Read more >
electron-rebuild - npm Package Health Analysis - Snyk
Electron supporting package to rebuild native node modules against the currently installed electron For more information about how to use this package see ......
Read more >
User Guide - Open Build Service
This guide is intended for users of Open Build Service. The rst part describes basic work- flows for working with packages on Open...
Read more >
Faster Multi-Platform Builds: Dockerfile Cross-Compilation ...
This way, you get an image that runs on the same machine you are working on. In order to build for a different...
Read more >
All the Electron Docs! | Electron
userInfo Object - App-specific state to store for use by another device. ... There is one important caveat: Native Node.js modules (that is,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found