Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an exception if native modules are being rebuilt and the host platform is not the target platform #380

Open
3 tasks done
avivsalman opened this issue Dec 4, 2017 · 12 comments

Comments

@avivsalman
Copy link

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

I am using windows server 2012 R2 X64 as the main develop server, when i am packing my project i get for windows X32/X64 everything are good, when i am create package for linux x32/x64 and i am trying to run it in linux ubuntu 16.04, i getting error from the node native module that i installed (work fine in windows), the module is "serialport".

this is the error that i get when i am trying to run the project:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: /home/pos/dp-linux-x64/resources/app/node_modules/serialport/build/Release/serialport.node: invalid ELF header
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at bindings (/home/pos/dp-linux-x64/resources/app/node_modules/bindings/bindings.js:81:44)
at Object. (/home/pos/dp-linux-x64/resources/app/node_modules/serialport/lib/bindings/linux.js:2:36)

(dp:9425): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9425): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9425): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9425): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

after that i amd trying to rebuild the ,odule in ubuntu and replcae the folder in npm mudules, then i get that the version of node are diffrents:

(dp:9687): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9687): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9687): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
START
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/pos/dp-linux-x64/resources/app/node_modules/serialport/build/Release/serialport.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using npm rebuild ornpm install).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at bindings (/home/pos/dp-linux-x64/resources/app/node_modules/bindings/bindings.js:81:44)
at Object. (/home/pos/dp-linux-x64/resources/app/node_modules/serialport/lib/bindings/linux.js:2:36)

(dp:9687): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9687): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9687): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(dp:9687): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

Console output when you run electron-forge with the environment variable DEBUG=electron-forge:*. (Instructions on how to do so here). Please include the stack trace if one exists.

Put the console output here

What command line arguments are you passing?

Put the arguments here

What does your config.forge data in package.json look like?

  "config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {
        "icon": "./DokoPoint.ico",
        "packageManager": "npm",
        "platform": "all",
        "arch": "all"
      },
      "electronWinstallerConfig": {
        "name": "dp"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "dp"
      }
    }
  },

please help as soon as posible its very urgent for me, thanks 👍

@malept
Copy link
Member

malept commented Dec 4, 2017

Are you trying to build a package for a Linux target platform on a Windows host platform? If so, that won't work because Node doesn't have a concept of cross-compiling native modules.

@malept
Copy link
Member

malept commented Dec 4, 2017

Also, specifying platform and arch in config.forge.electronPackagerConfig won't do anything, per the README.

@avivsalman
Copy link
Author

yes but when i run electron-forge package --arch=ia32 --platform=linux its make me package for linux system, so its dont work?

@malept
Copy link
Member

malept commented Dec 4, 2017

Rebuilding the native module won't work if your target platform is not the same as the host platform. You'll need to use a Linux VM to build Linux distributables (and a macOS machine, if you choose to create a darwin/mas target).

I'm surprised it doesn't throw an exception when it gets to the rebuild stage. @MarshallOfSound it would be cool if we could detect inside Forge if we need to rebuild a native module, and process.platform != target_platform.

@malept malept changed the title Ubuntu package get error for native modules Throw an exception if native modules are being rebuilt and the host platform is not the target platform Dec 4, 2017
@avivsalman
Copy link
Author

so what version of linux do you suggest to install and build? because i tried what you say on ubuntu 16.04 and electron-forge dont worked currectlly.

@malept
Copy link
Member

malept commented Dec 4, 2017

Ubuntu 16.04 works fine (that is what our tests use). I would suggest that instead of installing Forge globally, you add electron-forge to devDependencies.

@avivsalman
Copy link
Author

this is the error that i get when i am trying to install the electron-forge in linux:

oh oh Error: EACCES: permission denied, stat '/root/.bashrc'
at Error (native)
/usr/lib
└── (empty)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: appdmg@^0.4.5 (node_modules/electron-forge/node_modules/electron-installer-dmg/node_modules/appdmg):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for appdmg@0.4.5: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.10.0-28-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "electron-forge"
npm ERR! node v6.12.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! electron-forge@4.1.5 install: node tabtab-install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-forge@4.1.5 install script 'node tabtab-install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-forge package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node tabtab-install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs electron-forge
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls electron-forge
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pos/projects/dokoPOS/npm-debug.log
npm ERR! code 1

@malept
Copy link
Member

malept commented Dec 4, 2017

As I mentioned in my previous comment, install Forge locally in your project, not globally.

@avivsalman
Copy link
Author

ok i installed as you say but now the system dont reconize the electron-forge command.. so how i can run electron-forge init test?

@malept
Copy link
Member

malept commented Dec 4, 2017

I assumed you were trying to build your existing project instead of creating a new project.

Workarounds are described #321 (comment) and #321 (comment).

@malept
Copy link
Member

malept commented Dec 8, 2017

Fixing the bug "Throw an exception if native modules are being rebuilt and the host platform is not the target platform" is turning out to be more complicated than I'd like, because I can't say "stop the rebuild promise when it hits the criteria". I think what's going to happen is that we'll need to walk the node_modules tree once (in an afterCopy hook) for both pruning and rebuild purposes, and then use that data to make decisions about what to prune and what to rebuild (if it can even rebuild).

@MarshallOfSound
Copy link
Member

MarshallOfSound commented Jan 2, 2018

@malept The easiest way to do this is to provide our own walker to rebuild and make rebuild export the logic it uses to determine if a Module is a native module or not 👍

I'll look at tackling that next week when I'm not on beach wifi 😆

dsanders11 pushed a commit that referenced this issue Jan 14, 2023
This PR adds a Contributing section to the README and descriptive text for running Fiddle from source in CONTRIBUTING.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants