thegecko / webbluetooth

Node.js implementation of the Web Bluetooth Specification
https://thegecko.github.io/webbluetooth/
MIT License
141 stars 21 forks source link

Compatibility of build/Release/simpleble.node #132

Open cwilling opened 7 months ago

cwilling commented 7 months ago

When running any example, the supplied simpleble.node generates an error:

chris@d8:~/src/webbluetooth$ node examples/selector.js 
/home/chris/src/webbluetooth/node_modules/bindings/bindings.js:121
        throw e;
        ^

Error: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /home/chris/src/webbluetooth/build/Release/simpleble.node)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (/home/chris/src/webbluetooth/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/home/chris/src/webbluetooth/dist/adapters/simpleble.js:29:36)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  code: 'ERR_DLOPEN_FAILED'
}

I can fix this locally by running npm run build:all which generates a new simpleble.node and everything works fine.

I initially thought the error would be due to your build machine having a glibc version which is too recent for what I have on the machine I'm using. I see in your .github/workflows/prebuild.yml that linux-x64 jobs run on ubuntu-latest and maybe that is a problem for other systems out in the wild (not everyone wants/is able to run the very latest). However I also tried all this on another machine running Ubuntu 22.04 (full updated) and had the same issue so I'm a bit confused.

thegecko commented 7 months ago

@cwilling to help me tie down the issue, can you confirm if this is broken in the released versions? I know you were testing with some unreleased binaries.

cwilling commented 7 months ago

On a fresh machine, a git clone (after pull of #131), submodule update & npm install results in a simpleble.node dated Aug 23 i.e. the old version. If I replace it with the artifacts version from earlier today (Dec 2 05:30), all works OK. Also OK if I do npm run build:all - a good version of simpleble.node is produced.

The problem is therefore that npm install doesn't pull the correct simpleble.node. I see that I have a file ~/.npm/_prebuilds/673995-webbluetooth-v3.1.0-napi-v6-linux-x64.tar.gz which I presume is what provides the (wrong) simpleble.node.

cwilling commented 7 months ago

However back on my normal machine with glibc-2.33, even the newer artifacts version fails because it wants glibc-2.34. In that case the only solution is to rebuild simpleble.node locally.

I'm not sure there's anything you can do about that - probably a result of ubunt-latest in your workflow.

thegecko commented 7 months ago

OK, I think the best fix for this will be to use prebuildify-cross in a similar way to how we do it in node-usb. This will require prebuildify to support cmake-js, which I'll look in to.