matrix-org / matrix-rust-sdk-bindings

Language bindings for matrix-rust-sdk
Apache License 2.0
3 stars 5 forks source link

`yarn` is required to build the bindings #5

Open anoadragon453 opened 2 years ago

anoadragon453 commented 2 years ago

On attempting to install matrix-bot-sdk (a project which uses this library), the check-exists.js script runs, which tries to build these bindings.

https://github.com/matrix-org/matrix-rust-sdk-bindings/blob/049d1512e49213052b91755ea036416a6577fdc0/crates/matrix-sdk-crypto-nodejs/check-exists.js#L6-L10

This requires the user to have yarn installed, which isn't always the case:

$ npm i -s matrix-bot-sdk@beta --verbose
npm verb cli [
npm verb cli   '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'i',
npm verb cli   '-s',
npm verb cli   'matrix-bot-sdk@beta',
npm verb cli   '--verbose'
npm verb cli ]
npm info using npm@8.5.0
npm info using node@v16.14.2
... REMOVED FOR BREVITY
npm timing build:link:node_modules/matrix-bot-sdk/node_modules/mkdirp Completed in 1ms
npm timing build:link:node_modules/postcss/node_modules/nanoid Completed in 2ms
npm timing build:link Completed in 2ms
npm info run @turt2live/matrix-sdk-crypto-nodejs@0.1.0-beta.10 postinstall node_modules/@turt2live/matrix-sdk-crypto-nodejs node check-exists.js
npm info run @turt2live/matrix-sdk-crypto-nodejs@0.1.0-beta.10 postinstall { code: 127, signal: null }
npm timing reify:rollback:createSparse Completed in 67ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:i Completed in 3282ms
npm verb stack Error: command failed
npm verb stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack     at ChildProcess.emit (node:events:526:28)
npm verb stack     at maybeClose (node:internal/child_process:1092:16)
npm verb stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm verb pkgid @turt2live/matrix-sdk-crypto-nodejs@0.1.0-beta.10
npm verb cwd /Users/user/projects/my-project
npm verb Darwin 21.4.0
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "-s" "matrix-bot-sdk@beta" "--verbose"
npm verb node v16.14.2
npm verb npm  v8.5.0
npm ERR! code 127
npm ERR! path /Users/user/projects/my-project/node_modules/@turt2live/matrix-sdk-crypto-nodejs
npm ERR! command failed
npm ERR! command sh -c node check-exists.js
**npm ERR! /bin/sh: yarn: command not found**
npm verb exit 127
npm timing npm Completed in 3406ms

npm verb code 127

Is it necessary to use yarn for this, or can we use npm here? (It seems that at the end of the day this is all just wrapping calls to napi):

https://github.com/matrix-org/matrix-rust-sdk-bindings/blob/e1c5c8c81e32282d4cdd9e1ece61ea17b45cfbfb/crates/matrix-sdk-crypto-nodejs/package.json#L22-L39