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

electron-rebuild: failed to rebuild node_modules/@hyperswarm/dht/node_modules/sodium-native #70

Open
raphael10-collab opened this issue Dec 2, 2020 · 21 comments

Comments

@raphael10-collab
Copy link

raphael10-collab commented Dec 2, 2020

In my electron-react-typescript project I added hyperswarm:

yarn add hyperswarm
yarn add v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "ipfs-core > [email protected]" has unmet peer dependency "abort-controller@*".
warning "react-bootstrap > @restart/[email protected]" has incorrect peer dependency "react@^16.8.0".
warning " > [email protected]" has incorrect peer dependency "react@^16.3.0".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.3.0".
warning "webpack-dev-server > [email protected]" has incorrect peer dependency "webpack@^4.0.0".
warning "[email protected]" is missing a bundled dependency "node-pre-gyp". This should be reported to the package maintainer.
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 14 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ @hyperswarm/[email protected]
├─ @hyperswarm/[email protected]
├─ @hyperswarm/[email protected]
├─ @hyperswarm/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 9.31s.

When electron-rebuild-ing :

(base) marco@pc01:~/webMatters/electronMatters/GGC$ $(npm bin)/electron-rebuild
⠧ Building module: sodium-native, Completed: 0gyp info find Python using Python version 3.7.4 found at "/home/marco 
/anaconda3/bin/python3"
⠇ Building module: sodium-native, Completed: 0gyp http GET https://www.electronjs.org/headers/v11.0.3/node-v11.0.3-
headers.tar.gz
⠇ Building module: sodium-native, Completed: 0gyp http 200 https://www.electronjs.org/headers/v11.0.3/node-v11.0.3-
headers.tar.gz
⠙ Building module: sodium-native, Completed: 0gyp http GET https://www.electronjs.org/headers/v11.0.3/SHASUMS256.txt
⠙ Building module: sodium-native, Completed: 0gyp http 200 https://www.electronjs.org/headers/v11.0.3/SHASUMS256.txt
gyp info spawn /home/marco/anaconda3/bin/python3
gyp info spawn args [
gyp info spawn args   '/home/marco/webMatters/electronMatters/GGC/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm/dht/node_modules
/sodium-native/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/marco/webMatters/electronMatters/GGC/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm/dht/node_modules
/sodium-native/11.0.3/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm
/dht/node_modules/sodium-native/11.0.3',
gyp info spawn args   '-Dnode_gyp_dir=/home/marco/webMatters/electronMatters/GGC/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm 
/dht/node_modules/sodium-native/11.0.3/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm
/dht/node_modules/sodium-native',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
⠸ Building module: sodium-native, Completed: 0gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm/dht/node_modules
/sodium-native/build'
  CC(target) Release/obj.target/sodium/binding.o
In file included from ../binding.c:5:
../libsodium/src/libsodium/include/sodium.h:5:10: fatal error: sodium/version.h: No such file or directory
    5 | #include "sodium/version.h"
     |            ^~~~~~~~~~~~~~~~~~
compilation terminated.
sodium.target.mk:123: recipe for target 'Release/obj.target/sodium/binding.o' failed
make: *** [Release/obj.target/sodium/binding.o] Error 1
make: Leaving directory '/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm/dht/node_modules
/sodium-native/build'
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild '/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm/dht/node_modules   
/sodium-native'.
Error: `make` failed with exit code: 2

Error: node-gyp failed to rebuild '/home/marco/webMatters/electronMatters/GGC/node_modules/@hyperswarm  
/dht/node_modules/sodium-native'.
Error: `make` failed with exit code: 2

    at ModuleRebuilder.rebuildNodeGypModule (/home/marco/webMatters/electronMatters/GGC/node_modules/electron-rebuild
/lib/src/module-rebuilder.js:193:19)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Rebuilder.rebuildModuleAt (/home/marco/webMatters/electronMatters/GGC/node_modules/electron-rebuild/lib/src
/rebuild.js:190:9)
    at async Rebuilder.rebuild (/home/marco/webMatters/electronMatters/GGC/node_modules/electron-rebuild/lib/src
/rebuild.js:152:17)
    at async /home/marco/webMatters/electronMatters/GGC/node_modules/electron-rebuild/lib/src/cli.js:146:9

Other info:

node version: v.14.5.0
"devDependencies": {
  "@types/react": "^17.0.0",
  "@types/react-dom": "^17.0.0",
  "electron: "11.0.2"
 },
"dependencies": {
  "react": "^17.0.1",
   "react-dom": "^17.0.1"
 }

How to solve the problem?

@mafintosh
Copy link
Contributor

@raphael10-collab is the sodium prebuild not working for you? normally you'd never rebuild sodium

@raphael10-collab
Copy link
Author

Hi @mafintosh !

The problem comes from here:

(base) marco@pc01:~/webMatters/electronMatters/GGC$ yarn start
yarn run v1.22.5
$ npm run build && electron ./dist/main.js

> [email protected] build /home/marco/webMatters/electronMatters/GGC
> tsc

ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Reading config file from "/home/marco/.config/GGC/config
/init.json" ...
ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Inizializing ConfigurationPersistence
ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Restore "locale"
ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Restore "env"
ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Restore "enableSpellChecking" 
ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Restore "showMenu"
ℹ️  ggc/desktop/ConfigurationPersistence [2020-12-02 19:11:32] Restore "shouldAutoLaunch"
App threw an error during load
Error: The module '/home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/build/Release/sodium.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1203:18)
    at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
    at Module.load (internal/modules/cjs/loader.js:992:32)
    at Module._load (internal/modules/cjs/loader.js:885:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12694)
    at Module.require (internal/modules/cjs/loader.js:1032:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at load (/home/marco/webMatters/electronMatters/GGC/node_modules/node-gyp-build/index.js:21:10)
    at Object.<anonymous> (/home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/index.js:1:39)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/build/Release/sodium.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1203:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
at Module.load (internal/modules/cjs/loader.js:992:32)
at Module._load (internal/modules/cjs/loader.js:885:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12694)
at Module.require (internal/modules/cjs/loader.js:1032:19)
at require (internal/modules/cjs/helpers.js:72:18)
at load (/home/marco/webMatters/electronMatters/GGC/node_modules/node-gyp-build/index.js:21:10)
at Object.<anonymous> (/home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/index.js:1:39)

This is why I tried to use electron-rebuild.

@mafintosh
Copy link
Contributor

That looks like a pretty old version of sodium, can you check somehow?

@raphael10-collab
Copy link
Author

Sorry for the question... how to check the version of the sodium lib?
I didn't find any reference in /node_modules/node-gyp/package.json and /node_modules/hyperswarm/package

@mafintosh
Copy link
Contributor

You can see the path in the problem you posted here #70 (comment), ie /home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/package.json

@mafintosh
Copy link
Contributor

But I see now also that, that dep was rebuilt as well. In general don't rebuild sodium, utp-native or any of the prebuilds we ship. It'll create a lot more problems like this with interop than if you don't :)

@raphael10-collab
Copy link
Author

raphael10-collab commented Dec 2, 2020

/home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/package.json :

"version": "2.4.9"

Do you think that upgrading sodium-native to the latest version would solve the problem, or should I only re-install hyperswarm?

@mafintosh
Copy link
Contributor

mafintosh commented Dec 2, 2020 via email

@raphael10-collab
Copy link
Author

Now /home/marco/webMatters/electronMatters/GGC/node_modules/sodium-native/package.json :

"version": "3.2.0"

Still get:

App threw an error during load
Error: The module '/home/marco/webMatters/electronMatters/GGC/node_modules/noise-protocol/node_modules/sodium-native
/build/Release/sodium.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing

I removed node_modules folder and yarn.lock file.
Then I re-installed all the packages.
But still the same problem.

@derhuerst
Copy link

Could it be that you updated sodium-native to the latest version but noise-protocol has its own sodium-native dependency? npm usually does this whenever you want a version of package that is incompatible with the version that a dependency wants; In this case, npm nests the dependency's package. You can use npm ls to see the version of the nested dependency, maybe this will help.

@mafintosh
Copy link
Contributor

Latest noise-protocol uses latest sodium also. All of the hyper* deps are on sodium 3.

@mafintosh
Copy link
Contributor

But since you have a build folder inside sodium above, something is still rebuilding. Did you clean out all your deps and reinstalled? You sure nothing is compiling or that you aren't recompiling anything?

When you recompile you loose the cross node/electron compat that the prebuilds give you.

@raphael10-collab
Copy link
Author

raphael10-collab commented Dec 3, 2020

This is the complete list of dependencies obtained through yarn list command:
yarnList.txt
I'm trying to distill from your kind suggestions the steps I need to follow.

From the complete list of dependencies I see that sodium is version 3.something in these packages:
@hyperswarm/[email protected] ,
@hyperswarm/[email protected],
[email protected],
[email protected] .

But it is version 2.something as dependency in other packages:
[email protected] ,
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

So...should I remove the sodium dependency of each package if it is version 2.something, and re-install it @latest or should I do something else?

@mafintosh
Copy link
Contributor

What's pulling in those deps with version 2? Nothing in our stack should be doing that.

@raphael10-collab
Copy link
Author

Sorry Mathias. May be to my lack of knowledge, I do not understand.
Should I upgrade every sodium package to version 3?

@mafintosh
Copy link
Contributor

@raphael10-collab no problem, let me try to be a bit more clear.

Some parent dep in your dependency tree in your project is pulling in a legacy dep that uses sodium 2. For me to easier help you i need to know what parent dep that is. Could you post the output of npm ls from your project? Then I can take a look :)

@raphael10-collab
Copy link
Author

@mafintosh this is the complete dependencies tree:
yarnList.txt

@mafintosh
Copy link
Contributor

I think that list is deduped, but I think hypermerge in there needs a hypercore major bump. We should make an issue for that on that repo. You are using that one yea?

@raphael10-collab
Copy link
Author

I now redone the same list with this command: yarn list > yarnList.txt :
yarnList.txt

Yes, I'm using hypercore.
I can make an issue in github for hypercore's library asking for upgrading their sodium dependencies. And it would be helpful if you can give them your voice as well

@mafintosh
Copy link
Contributor

It's not hypercore, Hypercore is using latest sodium. It's the dep that's using an old version of Hypercore that needs to be bumped to use latest Hypercore, among those is Hypermerge (which we don't maintain)

@raphael10-collab
Copy link
Author

@mafintosh I just made an issue in Hypermerge's GitHub page about the version of Hypercore used: automerge/hypermerge#88

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

3 participants