Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

secp256k1 dependency requires python2 but not explicitly referenced #2

Closed
laboon opened this issue May 15, 2019 · 3 comments
Closed

Comments

@laboon
Copy link

laboon commented May 15, 2019

DESCRIPTION

The npm install script calls "python" but does not reference an explicit version. However it depends on python2. If python3 is installed and is set as the default python, the install will fail. However, there is a simple workaround, setting default python to be python2 (see WORKAROUND).

TO REPRODUCE

  1. Install python3 and have that as your default "python"
  2. Run npm i -g polkadot-deployer

EXPECTED BEHAVIOR

Installs

OBSERVED BEHAVIOR

Error in secp256k1 dependency - see below

WORKAROUND

I simply aliased my python and pip to call explicitly call version 2:

alias python=python2
alias pip=pip2

Maybe just add this to the README.md if it doesn't work on someone's machine?

NOTES

Output from my console

(20027) $ npm i -g polkadot-deployer
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
/Users/laboon/.nvm/versions/node/v10.7.0/bin/polkadot-deployer -> /Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/index.js

[email protected] install /Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1
npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."

[email protected] rebuild /Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1
node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Python executable "/usr/local/opt/python/libexec/bin/python" is v3.7.3, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack at PythonFinder.failPythonVersion (/Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:492:19)
gyp ERR! stack at PythonFinder. (/Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:474:14)
gyp ERR! stack at ChildProcess.exithandler (child_process.js:282:7)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:961:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:380:11)
gyp ERR! stack at Socket.emit (events.js:182:13)
gyp ERR! stack at Pipe._handle.close (net.js:599:12)
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/Users/laboon/.nvm/versions/node/v10.7.0/bin/node" "/Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/laboon/.npm/_logs/2019-05-15T14_52_52_462Z-debug.log
Secp256k1 bindings compilation fail. Pure JS implementation will be used.

@fgimenez
Copy link
Contributor

Thanks for reporting! :)

Hmm this is weird, having python3 as the default i can't reproduce the issue:

$ python --version
Python 3.6.7
$ npm i -g polkadot-deployer
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
/home/fgimenez/.nvm/versions/node/v10.7.0/bin/polkadot-deployer -> /home/fgimenez/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/index.js

> [email protected] install /home/fgimenez/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild /home/fgimenez/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1
> node-gyp rebuild

make: Entering directory '/home/fgimenez/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1/build'
  CXX(target) Release/obj.target/secp256k1/src/addon.o
  CXX(target) Release/obj.target/secp256k1/src/privatekey.o
../src/privatekey.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE privateKeyNegate(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/privatekey.cc:73:30: warning: ignoring return value of ‘int secp256k1_ec_privkey_negate(const secp256k1_context*, unsigned char*)’, declared with attribute warn_unused_result [-Wunused-result]
   secp256k1_ec_privkey_negate(secp256k1ctx, &private_key[0]);
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CXX(target) Release/obj.target/secp256k1/src/publickey.o
  CXX(target) Release/obj.target/secp256k1/src/signature.o
  CXX(target) Release/obj.target/secp256k1/src/ecdsa.o
  CXX(target) Release/obj.target/secp256k1/src/ecdh.o
  CC(target) Release/obj.target/secp256k1/src/secp256k1-src/src/secp256k1.o
  CC(target) Release/obj.target/secp256k1/src/secp256k1-src/contrib/lax_der_parsing.o
  CC(target) Release/obj.target/secp256k1/src/secp256k1-src/contrib/lax_der_privatekey_parsing.o
  SOLINK_MODULE(target) Release/obj.target/secp256k1.node
  COPY Release/secp256k1.node
make: Leaving directory '/home/fgimenez/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1/build'
+ [email protected]
added 181 packages from 207 contributors in 33.378s

Anyway, maybe your system behaves differently, after reading a bit about the issue here nodejs/node-gyp#746 looks like it is possible to pass the python version to use in the npm install command, something like npm i -g --python=python2.7 polkadot-deployer. Does this work for you? I would prefer this approach if it works, as you suggest add a note in the readme in case anyone finds the same issue.

@laboon
Copy link
Author

laboon commented May 16, 2019

It looks like it is working for me now; maybe there was some sort of transient issue with a dependency? It falls back to the pure JS implementation just like yours.

> [email protected] install /Users/laboon/.nvm/versions/node/v10.7.0/lib/node_modules/polkadot-deployer/node_modules/secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."
...

I'm fine closing as I cannot reproduce.

@fgimenez
Copy link
Contributor

@laboon ok thx, closing then (i missed your response :))

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

No branches or pull requests

2 participants