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

npm test on m1 hardware #294

Open
nichoth opened this issue Dec 20, 2021 · 9 comments
Open

npm test on m1 hardware #294

nichoth opened this issue Dec 20, 2021 · 9 comments

Comments

@nichoth
Copy link
Contributor

nichoth commented Dec 20, 2021

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 [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: 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 [email protected]: 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
@staltz
Copy link
Member

staltz commented Dec 20, 2021

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.

@nichoth
Copy link
Contributor Author

nichoth commented Dec 20, 2021

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

@staltz
Copy link
Member

staltz commented Dec 20, 2021

Thanks.

Just to rule out something, try node 12 or 14

@nichoth
Copy link
Contributor Author

nichoth commented Dec 20, 2021

% 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.

@nichoth
Copy link
Contributor Author

nichoth commented Dec 20, 2021

I have confirmed that npm test does work on the old computer, so it looks like it is just an error with new macs.

@nichoth nichoth closed this as completed Dec 20, 2021
@staltz
Copy link
Member

staltz commented Dec 20, 2021

You might need nj-cli, and Rust. See the requirements for building ssb-validate2-rsjs-node

@nichoth
Copy link
Contributor Author

nichoth commented Dec 20, 2021

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

@nichoth nichoth changed the title npm ERR! code 126 on npm install npm install on m1 hardware Dec 20, 2021
@nichoth nichoth reopened this Dec 20, 2021
@nichoth nichoth changed the title npm install on m1 hardware npm test on m1 hardware Dec 27, 2021
@nichoth
Copy link
Contributor Author

nichoth commented Dec 28, 2021

Got the issue with Cargo.toml done (thanks @staltz)

Now when I try npm test it returns this

ssb-db2 master % npm test

> [email protected] 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'
}

@nichoth
Copy link
Contributor Author

nichoth commented Jan 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants