node-argon2 icon indicating copy to clipboard operation
node-argon2 copied to clipboard

argon2 package.json is not node-pre-gyp ready

Open dotlambda opened this issue 1 year ago • 10 comments
trafficstars

Steps to reproduce

Run npx @mapbox/node-pre-gyp rebuild inside node-argon2's git repo.

Actual behaviour

$ node-pre-gyp rebuild
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | x64
node-pre-gyp ERR! UNCAUGHT EXCEPTION 
node-pre-gyp ERR! stack Error: argon2 package.json is not node-pre-gyp ready:
node-pre-gyp ERR! stack package.json must declare these properties: 
node-pre-gyp ERR! stack binary.module_name
node-pre-gyp ERR! stack binary.module_path
node-pre-gyp ERR! stack binary.host
node-pre-gyp ERR! stack     at validate_config (/nix/store/23papjdi7hbad05smk29fndmkwys9mzs-node-pre-gyp-1.0.11/lib/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js:220:11)
node-pre-gyp ERR! stack     at module.exports.evaluate (/nix/store/23papjdi7hbad05smk29fndmkwys9mzs-node-pre-gyp-1.0.11/lib/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js:279:3)
node-pre-gyp ERR! stack     at clean (/nix/store/23papjdi7hbad05smk29fndmkwys9mzs-node-pre-gyp-1.0.11/lib/node_modules/@mapbox/node-pre-gyp/lib/clean.js:16:27)
node-pre-gyp ERR! stack     at self.commands.<computed> [as clean] (/nix/store/23papjdi7hbad05smk29fndmkwys9mzs-node-pre-gyp-1.0.11/lib/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:86:37)
node-pre-gyp ERR! stack     at run (/nix/store/23papjdi7hbad05smk29fndmkwys9mzs-node-pre-gyp-1.0.11/lib/node_modules/@mapbox/node-pre-gyp/lib/main.js:81:30)
node-pre-gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
node-pre-gyp ERR! System Linux 6.9.10
node-pre-gyp ERR! command "node" "/nix/store/23papjdi7hbad05smk29fndmkwys9mzs-node-pre-gyp-1.0.11/lib/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp" "rebuild"
node-pre-gyp ERR! cwd /path/to/node-argon2
node-pre-gyp ERR! node -v v20.14.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.11

Environment

Operating system: NixOS

Node version: 20.14.0

Compiler version:

dotlambda avatar Jul 29 '24 21:07 dotlambda

Yeah, it hasn't been since the package moved from @mapbox/node-pre-gyp to node-gyp-build (see b47602840a259946039db8526ddd182d1430f634)

Is there a need to support @mapbox/node-pre-gyp when not using it directly?

ranisalt avatar Aug 03 '24 08:08 ranisalt

Is there a need to support @mapbox/node-pre-gyp when not using it directly?

I don't think there is but the README should be updated.

dotlambda avatar Aug 03 '24 08:08 dotlambda

Ah, absolutely. Feel free to open a pull request, or I will do it a little later :wink:

ranisalt avatar Aug 03 '24 09:08 ranisalt

We only really want to know how to recompile the prebuilt binaries so that they no segfault. We don't really care what tools are used for that 😅

We are receiving the same error as https://github.com/ranisalt/node-argon2/issues/302#issuecomment-1035201238 or https://github.com/ranisalt/node-argon2/issues/405

SuperSandro2000 avatar Aug 20 '24 13:08 SuperSandro2000

We tried rebuilding argon2 with cd node_modules/argon2; node-gyp rebuild but we still receive the error:

App threw an error during load
Error: /nix/store/lw0grjw4jfk7n2lf9vnw0xzxjxa5512v-bitwarden-desktop-2024.7.1/opt/Bitwarden/resources/app.asar.unpacked/node_modules/argon2/build/Release/argon2.node: undefined symbol: argon2_ctx
    at process.func [as dlopen] (node:electron/js2c/node_init:2:2559)
    at Module._extensions..node (node:internal/modules/cjs/loader:1470:18)
    at Object.func [as .node] (node:electron/js2c/node_init:2:2786)
    at Module.load (node:internal/modules/cjs/loader:1215:32)
    at Module._load (node:internal/modules/cjs/loader:1031:12)
    at c._load (node:electron/js2c/node_init:2:17025)
    at Module.require (node:internal/modules/cjs/loader:1240:19)
    at require (node:internal/modules/helpers:179:18)
    at load (/nix/store/lw0grjw4jfk7n2lf9vnw0xzxjxa5512v-bitwarden-desktop-2024.7.1/opt/Bitwarden/resources/app.asar/node_modules/node-gyp-build/node-gyp-build.js:22:10)
    at Object.<anonymous> (/nix/store/lw0grjw4jfk7n2lf9vnw0xzxjxa5512v-bitwarden-desktop-2024.7.1/opt/Bitwarden/resources/app.asar/node_modules/argon2/argon2.cjs:7:32)
A JavaScript error occurred in the main process

First of all: is that correct to rebuild the library now? What are we doing wrong?

SuperSandro2000 avatar Aug 20 '24 14:08 SuperSandro2000

@ranisalt Some advice would be helpful here as we are really stuck and in some migration pressure because electron 29 is soonish leaving nixpkgs unstable.

SuperSandro2000 avatar Aug 23 '24 15:08 SuperSandro2000

@SuperSandro2000 can you try running npm install --build-from-source? Seems to do what you need according to @mapbox/node-pre-gyp quick help

Edit: --build-from-source takes no argument, and rebuilds everything (hopefully you don't have a lot)

ranisalt avatar Aug 23 '24 15:08 ranisalt

node-gyp-ready doesn’t really matter, and is not the cause of the issue. The undefined symbol is due to LTO (for reasons unknown to me). Changing to use LTO was coupled with the change from node-gyp-ready to node-gyp-build (in b47602840a259946039db8526ddd182d1430f634). I’ve opened https://github.com/ranisalt/node-argon2/pull/415 to remove LTO from the build, which resolves the issue we were seeing building from source.

amarshall avatar Aug 25 '24 04:08 amarshall

Thanks @amarshall I'll publish v0.41.0 with your fix soon

ranisalt avatar Aug 25 '24 07:08 ranisalt

After a lot of trouble with npm, it's done :laughing: https://www.npmjs.com/package/argon2/v/0.41.0

ranisalt avatar Aug 25 '24 20:08 ranisalt

@dotlambda @SuperSandro2000 @amarshall can you confirm that it works from your side now?

ranisalt avatar Aug 29 '24 17:08 ranisalt

We don't directly consume this package, we get it proxied through bitwarden. In nixpkgs we patched a bit and rebuild the library and got things to work https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/bi/bitwarden-desktop/package.nix#L95 .

So I assume this got fixed but we only know for sure with the next updated of bitwarden.

SuperSandro2000 avatar Sep 02 '24 11:09 SuperSandro2000

OK, I use Bitwarden myself and will keep an eye out, but I consider this fixed.

ranisalt avatar Sep 04 '24 13:09 ranisalt