`npm test` on m1 hardware
nichoth opened this issue · comments
This is an npm
issue, however npm
is working fine for everything else, so I wonder why this is an error in this repo only.
ssb-db2 master % npm i
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 126
npm ERR! path /Users/nick/code/ssb-db2/node_modules/sodium-universal/node_modules/sodium-native
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! sh: /Users/nick/code/ssb-db2/node_modules/.bin/node-gyp-build: Permission denied
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nick/.npm/_logs/2021-12-20T16_54_05_114Z-debug-0.log
Please give more details, like versions of node and npm, and version of ssb-db2 or whether you're installing it on master or something.
thanks @staltz
This is on the master branch of ssb-db2
ssb-db2 master % npm --version
8.3.0
ssb-db2 master % node --version
v16.13.1
Thanks.
Just to rule out something, try node 12 or 14
% nvm version
v14.18.2
So npm i
seems to complete without an error on node version 14. However when I type npm test
it returns this:
Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=83 uv=1 armv=8 libc=glibc node=14.18.2
loaded from: /Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node
at Function.load.path (/Users/nick/code/ssb-db2/node_modules/node-bindgen-loader/index.js:62:9)
at load (/Users/nick/code/ssb-db2/node_modules/node-bindgen-loader/index.js:27:30)
at Object.<anonymous> (/Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node/index.js:5:41)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/nick/code/ssb-db2/db.js:10:7)
npm ERR! Test failed. See above for more details.
This is on a new mac computer with the m1 type of processor. Not sure if that has something to do with it.
I have confirmed that npm test
does work on the old computer, so it looks like it is just an error with new macs.
You might need nj-cli, and Rust. See the requirements for building ssb-validate2-rsjs-node
Hmm thank you. I have been following the ssb-validate2-rsjs-node instructions, and if I run the instructions in the dependency dir, /Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node
,
cargo install nj-cli
# generate release build of ssb-validate2-rsjs-node
npm run build
It returns this
error: could not find `Cargo.toml` in `/Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node` or any parent directory
Got the issue with Cargo.toml done (thanks @staltz)
Now when I try npm test
it returns this
ssb-db2 master % npm test
> ssb-db2@2.8.5 test
> tape test/*.js | tap-spec
node:internal/modules/cjs/loader:1183
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: dlopen(/Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node/dist/index.node, 0x0001): tried: '/Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node/dist/index.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/index.node' (no such file), '/usr/lib/index.node' (no such file)
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183: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 load (/Users/nick/code/ssb-db2/node_modules/node-bindgen-loader/index.js:27:10)
at Object.<anonymous> (/Users/nick/code/ssb-db2/node_modules/ssb-validate2-rsjs-node/index.js:5:41)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'ERR_DLOPEN_FAILED'
}
Note for posterity
There is a forked version of this where the tests pass on current m1 mac -- https://github.com/planetary-social/ssb-db2/tree/tests
This is because we've switched out ssb-validate2-rsjs-node
with ssb-validate2
, because the latter does not depend on having a rust dependency for this architecture.
There is a node-bindgen-loader issue about this too. The short version is that it seems as though ssb-validate2-rsjs-node
is not being compiled for m1.