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.

The realm native module cannot be rebuilt

See original GitHub issue

I am using Realm in an Electron application, which is built with electron-forge. The packaging process gets stuck at “Preparing to Package Application for arch: x64” if electron-forge start is run before electron-forge package.

I am developing on

  • macOS 10.13.4
  • node js 8.10.0
  • npm 5.6.0
  • python 2.7.14

Here is the example code to reproduce the never-end problem, realm-in-electron.

The steps to successfully package the electron app:

  1. clone the repository
  2. npm install
  3. electron-forge package --platform=darwin --arch=x64

Below is the log that the electron app is successfully packaged:

DEBUG=electron-packager electron-forge package
✔ Checking your system
⠋ Preparing to Package Application for arch: x64  electron-packager Electron Packager 11.1.0 +0ms
  electron-packager Node v8.10.0 +0ms
  electron-packager Host Operating system: darwin (x64) +0ms
  electron-packager Packager Options: {"asar":false,"overwrite":true,"packageManager":"npm","afterCopy":[null],"afterExtract":[null],"afterPrune":[null],"dir":"/Users/jackytsang/GithubRepos/realm_in_electron","arch":"x64","platform":"darwin","out":"/Users/jackytsang/GithubRepos/realm_in_electron/out","electronVersion":"1.8.4","quiet":true} +1ms
  electron-packager Target Platforms: darwin +0ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Inferring application name from productName in /Users/jackytsang/GithubRepos/realm_in_electron/package.json +0ms
  electron-packager Inferring appVersion from version in /Users/jackytsang/GithubRepos/realm_in_electron/package.json +0ms
  electron-packager Application name: realm_in_electron +10ms
  electron-packager Target Electron version: 1.8.4 +0ms
  electron-packager Ignored path regular expressions: [ '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
⠹ Preparing to Package Application for arch: x64  electron-packager Downloading Electron with options {"platform":"darwin","arch":"x64","version":"1.8.4"} +0ms
⠧ Preparing to Package Application for arch: x64  electron-packager Creating /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64-template +7s
  electron-packager Extracting /Users/jackytsang/.electron/electron-v1.8.4-darwin-x64.zip to /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64-template +1ms
⠼ Preparing to Package Application for arch: x64  electron-packager Initializing app in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64 from /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64-template template +0ms
⠴ Preparing to Package Application for arch: x64  electron-packager Ignored paths based on the out param: [ '/Users/jackytsang/GithubRepos/realm_in_electron/out' ] +9s
✔ Preparing to Package Application for arch: x64
✔ Compiling Application
  electron-packager Pruning modules via: npm prune --production +0ms
✔ Preparing native dependencies: 1 / 1
⠋ Packaging Application  electron-packager Renaming Electron to realm_in_electron in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/MacOS +3m
  electron-packager Renaming Electron Helper to realm_in_electron Helper in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS +2ms
  electron-packager Renaming Electron Helper EH to realm_in_electron Helper EH in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper EH.app/Contents/MacOS +0ms
  electron-packager Renaming Electron Helper NP to realm_in_electron Helper NP in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper NP.app/Contents/MacOS +0ms
  electron-packager Renaming Electron Helper.app to realm_in_electron Helper.app in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/Frameworks +1ms
  electron-packager Renaming Electron Helper EH.app to realm_in_electron Helper EH.app in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/Frameworks +0ms
  electron-packager Renaming Electron Helper NP.app to realm_in_electron Helper NP.app in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64/Electron.app/Contents/Frameworks +0ms
  electron-packager Moving /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm_in_electron-darwin-x64 to /Users/jackytsang/GithubRepos/realm_in_electron/out/realm_in_electron-darwin-x64 +1ms
✔ Packaging Application

The steps to reproduce the “never-end” problem:

  1. clone the repository
  2. npm install
  3. electron-forge start
  4. electron-forge package --platform=darwin --arch=x64

Here is the log by runing DEBUG=electron-packager electron-forge package --platform=darwin --arch=x64

Jackys-MacBook-Pro:realm-in-electron jackytsang$ DEBUG=electron-packager electn-forge package --platform=darwin --arch=x64
✔ Checking your system
⠋ Preparing to Package Application for arch: x64  electron-packager Electron Packager 11.1.0 +0ms
  electron-packager Node v8.10.0 +0ms
  electron-packager Host Operating system: darwin (x64) +0ms
  electron-packager Packager Options: {"asar":false,"overwrite":true,"packageManager":"npm","afterCopy":[null],"afterExtract":[null],"afterPrune":[null],"dir":"/Users/jackytsang/GithubRepos/realm-in-electron","arch":"x64","platform":"darwin","out":"/Users/jackytsang/GithubRepos/realm-in-electron/out","electronVersion":"1.8.4","quiet":true} +0ms
  electron-packager Target Platforms: darwin +1ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Inferring application name from productName in /Users/jackytsang/GithubRepos/realm-in-electron/package.json +0ms
  electron-packager Inferring appVersion from version in /Users/jackytsang/GithubRepos/realm-in-electron/package.json +1ms
  electron-packager Application name: realm-in-electron +6ms
  electron-packager Target Electron version: 1.8.4 +0ms
  electron-packager Ignored path regular expressions: [ '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt(-compile)?($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"darwin","arch":"x64","version":"1.8.4"} +0ms
⠸ Preparing to Package Application for arch: x64  electron-packager Removing /Users/jackytsang/GithubRepos/realm-in-electron/out/realm-in-electron-darwin-x64 due to setting overwrite: true +287ms
⠼ Preparing to Package Application for arch: x64  electron-packager Creating /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64-template +2s
  electron-packager Extracting /Users/jackytsang/.electron/electron-v1.8.4-darwin-x64.zip to /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64-template +1ms
⠧ Preparing to Package Application for arch: x64  electron-packager Initializing app in /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64/realm-in-electron-darwin-x64 from /var/folders/9y/7_hsjyyx7jx5dph83941r6tc0000gn/T/electron-packager/darwin-x64-template template +0ms
⠇ Preparing to Package Application for arch: x64  electron-packager Ignored paths based on the out param: [ '/Users/jackytsang/GithubRepos/realm-in-electron/out' ] +4s
⠧ Preparing to Package Application for arch: x64

config.forge in package.json:

"config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {
        "packageManager": "npm"
      },
      "electronWinstallerConfig": {
        "name": "realm_in_electron"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "realminelectron"
      }
    }
  }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maleptcommented, Apr 13, 2018

@mani0608 this is a different issue, please move the discussion to #434 and answer the questions I posed there.

0reactions
MarshallOfSoundcommented, May 3, 2018

This doesn’t appear to be 100% related to forge, we’re just triggering a normal node-gyp build of that native module through electron-rebuild. If it’s not working I’d suggest asking the realm folks why it’s not building 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
I am migrating from MongoDB Stitch to Realm in our React Native ... fails to build the application since it is unable to...
Read more >
Unable to add Realm to Electron App - Stack Overflow
Trying to add realm to an electron app, I get the following error. [0] ERROR in ./node_modules/realm/lib/browser/index.js [0] Module not ...
Read more >
Realm: Create reactive mobile apps in a fraction of the time
Prerequisites. Make sure your environment is set up to run React Native applications. Follow the React Native instructions for getting started.
Read more >
realm | Yarn - Package Manager
This project hosts the JavaScript versions of Realm. Currently we support React Native (JSC & Hermes on iOS & Android), Node.js and Electron...
Read more >
realm - npm
Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript versions of Realm.
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