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

node-hid prebuilds do not work with Electron 4, due to ABI incompatibilities #293

Closed
setpixel opened this issue Dec 29, 2018 · 25 comments
Closed

Comments

@setpixel
Copy link

setpixel commented Dec 29, 2018

Electron 4.0.0 was just released. It is the main release.

Electron 4.0.0 uses node 10.11.0.

It seems to build fine with rebuild, and it works when I require.

However, when I try to call hid.devices(), i get:

dyld: lazy symbol binding failed: Symbol not found: __ZN2v811HandleScope12CreateHandleEPNS_8internal10HeapObjectEPNS1_6ObjectE
  Referenced from: /Users/setpixel/git/shot-generator/node_modules/node-hid/build/Release/HID.node
  Expected in: flat namespace

dyld: Symbol not found: __ZN2v811HandleScope12CreateHandleEPNS_8internal10HeapObjectEPNS1_6ObjectE
  Referenced from: /Users/setpixel/git/shot-generator/node_modules/node-hid/build/Release/HID.node
  Expected in: flat namespace`
@todbot
Copy link
Contributor

todbot commented Dec 29, 2018

Hi,
Which OS are you on?

@todbot todbot changed the title node-hid does not work with latest Electron release. node-hid does not work with Electron v4.0.0 release. Dec 29, 2018
@todbot todbot closed this as completed in 3997045 Dec 29, 2018
@todbot
Copy link
Contributor

todbot commented Dec 29, 2018

Verified this on MacOS. Closed issue by accident.

@todbot todbot reopened this Dec 29, 2018
@setpixel
Copy link
Author

Yes mac, sorry I thought it was implied by the path, but I guess linux could be the same. sorry!

@setpixel
Copy link
Author

btw, thanks for your work on this module, it's great!!!!

@todbot
Copy link
Contributor

todbot commented Dec 29, 2018

Thanks! It's unfortunate it's such a pain that it seems to always break whenever a new Node or Electron version comes out. Seems the way for native Node modules though.

@todbot
Copy link
Contributor

todbot commented Dec 29, 2018

Note to self: I think this error message is essentially a Node version mismatch error between command-line Node v10 and the Node v10 inside of Electron.

That is, it seems like this is a problem with electron-rebuild (which hasn't had a new release since 30 Jul 2018)

@todbot
Copy link
Contributor

todbot commented Dec 29, 2018

I think I have a work-around fix for this.
You can check it out in todbot/electron-hid-toy
You should be able to do:

git clone https://github.com/todbot/electron-hid-toy
cd electron-hid-toy
npm install
npm run start

and see a list of HID devices, running in an Electron v4.0.0 window.

@todbot
Copy link
Contributor

todbot commented Dec 29, 2018

Note to self: It seems the main issue is that node-hid@0.7.4 has prebuilt binaries for Node v10 and Electron v3.x, but Node v10 is such a mess wrt native modules that electron-rebuild was getting confused, loading the prebuild for 0.7.4 for Electron v4 and not building from source. I think. Still investigating.

@setpixel
Copy link
Author

@todbot YEP!!! Totally works with my project. So good!

@todbot
Copy link
Contributor

todbot commented Dec 30, 2018

node-hid@0.7.6 released but prebuilds for Electron v4.0.0 still do not work correctly and give that dyld: lazy symbol binding failed. This seems to be a failure of prebuild.

Current strategy: remove prebuilds for Electron v4. This forces node-hid to be recompiled on npm install. This means you need a C compiler dev environment. See: https://github.com/node-hid/node-hid#to-build-node-hid-for-development

Keeping this issue open until a real solution is found. (thx @setpixel for reporting this)

@todbot todbot changed the title node-hid does not work with Electron v4.0.0 release. node-hid prebuilds do not work with Electron v4.0.0 release. Dec 30, 2018
@gniezen
Copy link

gniezen commented Jan 9, 2019

There seems to be more details on this issue here: electron/node-abi#55

TL;DR: The ABI for both Electron v3 and v4 is 64, but the builds are not compatible (probably because they switched from GYP to GN).

@todbot
Copy link
Contributor

todbot commented Jan 9, 2019

Thanks for finding that @gniezen! I was going down similar rabbit holes but gave up. Following that issue now though...

@todbot todbot changed the title node-hid prebuilds do not work with Electron v4.0.0 release. node-hid prebuilds do not work with Electron 4, due to ABI incompatibilities Jan 23, 2019
@adeperio
Copy link

Hi @todbot the implementation in todbot/electron-hid-toy works well for me with my mac builds (packaging and executing). I can also generate a windows build (which I am building on mac), but when I run the .exe that's when I run into problems.

It doesn't run on windows and I keep getting an error message on a file in the temp folder which says "this is not a valid win32 application"

Could this be something todo with bypassing using prebuilds?

image

@todbot
Copy link
Contributor

todbot commented Feb 14, 2019

Hi @adeperio, what version of Windows are you running?

@adeperio
Copy link

Hi @todbot, I'm running Win7 64bit and building specifically for that with electron-builder. I also have another native dependency (keytar) so I'm not sure if node-hid is the problem or if its keytar

@todbot
Copy link
Contributor

todbot commented Feb 14, 2019

Oh wait you are building a Windows executable on Mac? In general that seems to never work well. Try building on Windows

@adeperio
Copy link

adeperio commented Feb 14, 2019

@todbot Yea I've been building windows on Mac fro a while now. I've only started having problems after upgrading to Electron 4. I'd like to continue building Windows on Mac if possible. I'm not sure where to look for any changes in the compatibility between the upgrade to Electron 4 (from 1.8.6, where node-hid was working with windows being built on mac) to the latest node-hid. Is there anything else you think I could look at?

@adeperio
Copy link

adeperio commented Feb 14, 2019

@todbot I think I was using the prebuilt binaries before with nodehid, and the build seemed to be working with those. I noticed that prebuilt binaries are not included with nodehid 0.7.9? If that's the case, any idea if they may be coming out any time soon? Or if not, is there a way I can generate those prebuilt binaries myself?

@todbot
Copy link
Contributor

todbot commented Feb 14, 2019

yeah because of the node-abi bug referenced above, it's difficult currently to make Electron prebuilds for Electron 3 & 4. And that means we can't do Windows builds of projects with native modules on Mac (because you'd need a Windows compiler on Mac)

(although now that I look at that bug, perhaps the problem has been fixed as of a few days ago with Electron 4.0.4 that incorporates this fix: electron/electron#16687 )

I'll do some tests tomorrow.

@adeperio
Copy link

@todbot Thanks Tod, I've been following the comments around this ABI issue. Hopefully 4.0.4 has a fix? It would be useful to get new prebuilds with node-hid. If it helps, I was packaging windows up successfully on a mac machine prior to this on Electron 1.8.6 using the node-hid prebuilds. But we're now looking to upgrade from 1.8.6 to 4.0.4 and hence started running into this issue

@webees
Copy link

webees commented Feb 15, 2019

usb-detection: Command failed.
prebuild-install WARN install No prebuilt binaries found (target=4.0.4 runtime=electron arch=ia32 libc= platform=win32)

node-hid: Command failed.
Command: prebuild-install || node-gyp rebuild
prebuild-install WARN install No prebuilt binaries found (target=2.0.17 runtime=electron arch=ia32 libc= platform=win32)

system: windows10
electron: v4.0.4
node: v8.15.0
npm: [
node-hid
usb-detection
]

@todbot
Copy link
Contributor

todbot commented Feb 15, 2019

that looks like a problem with usb-detection, not node-hid.
I've not published an updated version of node-hid yet, apologies.

@adeperio
Copy link

Hi @todbot thank you, I actually just saw 0.7.7 come up on the releases page. Will look out for it on npm when it's available there and see if that brings me a step forward on my end

@todbot
Copy link
Contributor

todbot commented Feb 15, 2019

I believe this is fixed now in node-hid@0.7.7 thanks to Electron v4.0.4+.
Tested with an updated https://github.com/todbot/electron-hid-toy
Be sure to update your package.json to include updated electron, electron-rebuild, and electron-builder.

@adeperio
Copy link

Thanks @todbot can confirm from my end that 0.7.7 node-hid is now working with Electron 4.0.4!

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

5 participants