ssbc / ssb-validate2-rsjs-node

Cryptographic validation of Scuttlebutt messages, Node.js only
3 stars 1 forks source link

missing Rust prebuilds with Docker #15

Open luandro opened 2 years ago

luandro commented 2 years ago

Trying to run ssb-db2 on a freshly installed RaspbianOS (Pi 3+) running node v16.13. Also getting same error during install when trying to build a Docker image with ssb-db2.

npm ERR! code 1
npm ERR! path /home/dev/node_modules/ssb-validate2-rsjs-node
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! node:internal/errors:464
npm ERR!     ErrorCaptureStackTrace(err);
npm ERR!     ^
npm ERR! 
npm ERR! Error: spawn nj-cli ENOENT
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
npm ERR!     at onErrorNT (node:internal/child_process:477:16)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
npm ERR!   errno: -2,
npm ERR!   code: 'ENOENT',
npm ERR!   syscall: 'spawn nj-cli',
npm ERR!   path: 'nj-cli',
npm ERR!   spawnargs: [ 'build', '--release' ]
npm ERR! }

Any missing dependencies?

luandro commented 2 years ago

For the Dockerfile I had to add:

RUN apk update && apk add --no-cache rust cargo
RUN cargo install nj-cli
ENV PATH="/root/.cargo/bin:${PATH}"

That solves the error on install, but now getting this error on runtime:

Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/app/node_modules/ssb-validate2-rsjs-node/prebuilds/linux-x64/node.abi93.node)
luandro commented 2 years ago

Related to https://github.com/fraction/oasis/issues/747

staltz commented 2 years ago

Hmm, unfortunate. We should eventually have a way of installing ssb-db2 that bypasses rsjs, for emergencies. But in the meanwhile, I searched the web for solutions to the ld-linux-x86-64 missing, and I found this: https://github.com/vercel/vercel/issues/274#issuecomment-433790453

apt update
apt install libc6-compat

It's weird though, why is it getting the linux-x64 prebuild if raspberry pi is linux-arm (or linux-armv8)?

Also: https://dustri.org/b/error-loading-shared-library-ld-linux-x86-64so2-on-alpine-linux.html

luandro commented 2 years ago

Thanks @staltz!

I'm actually trying to build the Docker image from an amd64 linux machine. Added libc6-compat installation and did the linking. Getting a different error now:

Error: Error relocating /usr/src/app/node_modules/ssb-validate2-rsjs-node/prebuilds/linux-x64/node.abi93.node: __register_atfork: symbol not found

On the Pi I've been trying to run natively with node, but I was getting this:

Error: No native build was found for platform=linux arch=arm runtime=node abi=93 uv=1 armv=7 libc=glibc node=16.13.0
    loaded from: /home/pi/meshtastic-api/node_modules/ssb-validate2-rsjs-node

Had to create a build for arm by cloning ssb-validate2-rsjs-node to node_modules and running npm i and npm run build. With that I got it working on a Pi 4 running Raspbian 32 :tada: