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

Remove dependency on keccak NPM module. #356

Closed
MicahZoltu opened this issue May 5, 2019 · 2 comments · Fixed by #357
Closed

Remove dependency on keccak NPM module. #356

MicahZoltu opened this issue May 5, 2019 · 2 comments · Fixed by #357

Comments

@MicahZoltu
Copy link
Contributor

The keccak NPM module is a native module which requires node-gyp to properly install. This means the developer needs a fully Python dev-env setup, which can be problematic with Python 2.7 vs 3.0. Please use a native JS sha3 library rather than keccak so users don't need to install Python just to use solc without error.

A good alternative library for keccak hashing is https://github.com/emn178/js-sha3. It has no dependencies and works in node and browser.

PS > npm install

> [email protected] install C:\...\node_modules\keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild C:\...\node_modules\keccak
> node-gyp rebuild


C:\...\node_modules\keccak>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\...\node_modules\keccak
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
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 WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\...\AppData\Local\npm\npmrc\_logs\2019-05-05T02_48_08_179Z-debug.log
@MicahZoltu MicahZoltu changed the title Please don't depend on keccak NPM module. Remove dependency on keccak NPM module. May 5, 2019
@axic
Copy link
Member

axic commented May 15, 2019

The keccak NPM module is a native module which requires node-gyp to properly install.

I don't think this is correct. It is a module providing both native and JS-only bindings.

It would be nice to consider fixing keccak if you are experiencing issues with it. Have you reached out to the authors yet?

@MicahZoltu
Copy link
Contributor Author

@axic Yeah, there is a long thread in ethereumjs-utils and keccak and secp256k1 GitHub issues IIRC. Keccak is against going JS only, as they believe the purpose of their library is to wrap both native and JS into a single library, and if users don't like that then they should switch to depending on one or the other directly (which is exactly what I propose here).

The problem is node-gyp, it is notorious for causing problems on build infrastructure, Windows, and elsewhere. It isn't that keccak is doing anything wrong specifically other than they depend on node-gyp, which causes no end of trouble.

In the case of this library (solc) there is no need to use keccak instead of js-sha3, and as seen in #357 removing that dependency is quite easy.

@axic axic closed this as completed in #357 Jul 4, 2019
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

Successfully merging a pull request may close this issue.

2 participants