Level / community

Discussion, support and common information for projects in the community.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Package level with electron

theSherwood opened this issue · comments

I'm trying to package level with electron. Everything is working when I run electron in dev. But packaging the distributable is failing when electron-rebuild runs node-gyp on level. Are there any examples in the community of doing this? I'm aware of the electron-demo depo (https://github.com/Level/electron-demo) but it doesn't do any packaging.

I'm getting some errors when I attempt to package up level. So I'm unsure of where would be the best place for this issue: here, the level repo, or on an electron repo. If this isn't the right place, let me know. I'm pretty new to both level and electron. Some of this stuff is a little outside my wheelhouse.

The error is:

/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: 
      Unsupported architecture
#error Unsupported architecture

I'm using:

macOS Catalina 10.15.7
level@7.0.1
electron@20.0.2

This is the trace I'm getting:

  electron-rebuild assuming is prebuildify powered: leveldown +0ms
  electron-rebuild Checking for prebuilds for "leveldown" +0ms
  electron-rebuild Could not locate "/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/prebuilds/darwin-x64/electron.napi.node", "/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/prebuilds/darwin-x64/node.napi.node", or "/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/prebuilds/darwin-x64/electron.abi107.node" +1ms
  electron-rebuild rebuilding leveldown with args [
  'node',
  'node-gyp',
  'rebuild',
  '--runtime=electron',
  '--target=20.1.0',
  '--arch=x64',
  '--dist-url=https://www.electronjs.org/headers',
  '--build-from-source',
  '--verbose'
] +0ms
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb download using dist-url https://www.electronjs.org/headers
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
⠼ Preparing native dependencies: 0 / 1gyp verb find Python - executable path is "/usr/local/opt/python@3.9/bin/python3.9"
gyp verb find Python - executing "/usr/local/opt/python@3.9/bin/python3.9" to get version
⠴ Preparing native dependencies: 0 / 1gyp verb find Python - version is "3.9.12"
gyp info find Python using Python version 3.9.12 found at "/usr/local/opt/python@3.9/bin/python3.9"
gyp verb get node dir compiling against --target node version: 20.1.0
gyp verb command install [ '20.1.0' ]
gyp verb download using dist-url https://www.electronjs.org/headers
gyp verb install input version string "20.1.0"
gyp verb install installing version: 20.1.0
gyp verb install --ensure was passed, so won't reinstall if already installed
⠦ Preparing native dependencies: 0 / 1gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 20.1.0
gyp verb build dir attempting to create "build" dir: /Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/build
gyp verb build dir "build" dir needed to be created? Yes
gyp verb python symlink creating symlink to "/usr/local/opt/python@3.9/bin/python3.9" at "/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/build/node_gyp_bins/python3"
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/config.gypi
gyp verb common.gypi checking for gypi file: /Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/Users/adam/code/codex/codex/apps/electron/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   '/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/adam/code/codex/codex/apps/electron/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/adam/.electron-gyp/20.1.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/adam/.electron-gyp/20.1.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/adam/code/codex/codex/apps/electron/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/adam/.electron-gyp/20.1.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown',
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 ]
⠴ Preparing native dependencies: 0 / 1gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /Users/adam/.electron-gyp/20.1.0
gyp verb `which` succeeded for `make` /usr/bin/make
gyp verb bin symlinks adding symlinks (such as Python), at "/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown/build/node_gyp_bins", to PATH
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
  c++ -o Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/db/builder.o ../deps/leveldb/leveldb-1.20/db/builder.cc '-DNODE_GYP_MODULE_NAME=leveldb' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-DELECTRON_ENSURE_CONFIG_GYPI' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DUSING_ELECTRON_CONFIG_GYPI' '-DV8_COMPRESS_POINTERS' '-DV8_COMPRESS_POINTERS_IN_SHARED_CAGE' '-DV8_ENABLE_SANDBOX' '-DV8_SANDBOXED_POINTERS' '-DV8_31BIT_SMIS_ON_64BIT_ARCH' '-DV8_REVERSE_JSARGS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DSNAPPY=1' '-DLEVELDB_PLATFORM_POSIX=1' '-DOS_MACOSX=1' -I/Users/adam/.electron-gyp/20.1.0/include/node -I/Users/adam/.electron-gyp/20.1.0/src -I/Users/adam/.electron-gyp/20.1.0/deps/openssl/config -I/Users/adam/.electron-gyp/20.1.0/deps/openssl/openssl/include -I/Users/adam/.electron-gyp/20.1.0/deps/uv/include -I/Users/adam/.electron-gyp/20.1.0/deps/zlib -I/Users/adam/.electron-gyp/20.1.0/deps/v8/include -I../deps/leveldb/leveldb-1.20 -I../deps/leveldb/leveldb-1.20/include -I../deps/snappy/mac -I../deps/snappy/snappy  -O3 -gdwarf-2 -mmacosx-version-min=10.7 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -std=gnu++14 -stdlib=libc++ -fno-rtti -fno-exceptions -fno-strict-aliasing -arch x86_64 -arch arm64 -MMD -MF ./Release/.deps/Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/db/builder.o.d.raw  -std=c++17 -c
⠹ Preparing native dependencies: 0 / 1In file included from ../deps/leveldb/leveldb-1.20/db/builder.cc:5:
In file included from ../deps/leveldb/leveldb-1.20/db/builder.h:8:
In file included from ../deps/leveldb/leveldb-1.20/include/leveldb/status.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:60:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/string.h:61:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:27:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:32:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: 
      Unsupported architecture
#error Unsupported architecture
 ^
In file included from ../deps/leveldb/leveldb-1.20/db/builder.cc:5:
In file included from ../deps/leveldb/leveldb-1.20/db/builder.h:8:
In file included from ../deps/leveldb/leveldb-1.20/include/leveldb/status.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:60:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/string.h:61:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:27:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:33:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/machine/_types.h:34:2: error: 
      architecture not supported
#error architecture not supported
 ^
In file included from ../deps/leveldb/leveldb-1.20/db/builder.cc:5:
In file included from ../deps/leveldb/leveldb-1.20/db/builder.h:8:
In file included from ../deps/leveldb/leveldb-1.20/include/leveldb/status.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:60:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/string.h:61:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:27:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:55:9: error: 
      unknown type name '__int64_t'
typedef __int64_t       __darwin_...
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:56:9: error: 
      unknown type name '__int32_t'; did
      you mean '__int128_t'?
typedef __int32_t       __darwin_...
        ^
note: '__int128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:57:9: error: 
      unknown type name '__int32_t'; did
      you mean '__int128_t'?
typedef __int32_t       __darwin_...
        ^
note: '__int128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:60:9: error: 
      unknown type name '__uint32_t'; did
      you mean '__uint128_t'?
typedef __uint32_t      __darwin_...
        ^
note: '__uint128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:61:9: error: 
      unknown type name '__uint32_t'; did
      you mean '__uint128_t'?
typedef __uint32_t      __darwin_...
        ^
note: '__uint128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:62:9: error: 
      unknown type name '__uint64_t'
typedef __uint64_t      __darwin_...
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:68:9: error: 
      unknown type name
      '__darwin_natural_t'
typedef __darwin_natural_t __darw...
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:70:9: error: 
      unknown type name '__uint16_t'; did
      you mean '__uint128_t'?
typedef __uint16_t      __darwin_...
        ^
note: '__uint128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:71:9: error: 
      unknown type name '__int64_t'
typedef __int64_t       __darwin_...
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:72:9: error: 
      unknown type name '__int32_t'; did
      you mean '__int128_t'?
typedef __int32_t       __darwin_...
        ^
note: '__int128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:73:9: error: 
      unknown type name '__uint32_t'; did
      you mean '__uint128_t'?
typedef __uint32_t      __darwin_...
        ^
note: '__uint128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:74:9: error: 
      unknown type name '__int32_t'; did
      you mean '__int128_t'?
typedef __int32_t       __darwin_...
        ^
note: '__int128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:75:9: error: 
      unknown type name '__uint32_t'; did
      you mean '__uint128_t'?
typedef __uint32_t      __darwin_...
        ^
note: '__uint128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:76:9: error: 
      unknown type name '__uint32_t'; did
      you mean '__uint128_t'?
typedef __uint32_t      __darwin_...
        ^
note: '__uint128_t' declared here
In file included from ../deps/leveldb/leveldb-1.20/db/builder.cc:5:
In file included from ../deps/leveldb/leveldb-1.20/db/builder.h:8:
In file included from ../deps/leveldb/leveldb-1.20/include/leveldb/status.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:60:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/string.h:61:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:43:9: error: 
      unknown type name '__uint32_t'; did
      you mean '__uint128_t'?
typedef __uint32_t      __darwin_...
        ^
note: '__uint128_t' declared here
In file included from ../deps/leveldb/leveldb-1.20/db/builder.cc:5:
In file included from ../deps/leveldb/leveldb-1.20/db/builder.h:8:
In file included from ../deps/leveldb/leveldb-1.20/include/leveldb/status.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:60:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/string.h:152:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_ssize_t.h:30:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/machine/types.h:37:2: error: 
      architecture not supported
#error architecture not supported
 ^
In file included from ../deps/leveldb/leveldb-1.20/db/builder.cc:5:
In file included from ../deps/leveldb/leveldb-1.20/db/builder.h:8:
In file included from ../deps/leveldb/leveldb-1.20/include/leveldb/status.h:16:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:504:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string_view:175:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__string:57:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstring:60:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string.h:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/string.h:152:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types/_ssize_t.h:31:9: error: 
      unknown type name
      '__darwin_ssize_t'; did you mean
      '__darwin_blksize_t'?
typedef __darwin_ssize_t        ssize_t;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:56:25: note: 
      '__darwin_blksize_t' declared here
typedef __int32_t       __darwin_...
                        ^
⠸ Preparing native dependencies: 0 / 1fatal error: too many errors emitted,
      stopping now [-ferror-limit=]
⠴ Preparing native dependencies: 0 / 120 errors generated.
make: *** [Release/obj.target/leveldb/deps/leveldb/leveldb-1.20/db/builder.o] Error 1
✖ Preparing native dependencies: 0 / 1

An unhandled error has occurred inside Forge:
node-gyp failed to rebuild '/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `make` failed with exit code: 2


Error: node-gyp failed to rebuild '/Users/adam/code/codex/codex/apps/electron/node_modules/leveldown'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `make` failed with exit code: 2


    at NodeGyp.rebuildModule (/Users/adam/code/codex/codex/apps/electron/node_modules/electron-rebuild/lib/src/module-type/node-gyp.js:120:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ModuleRebuilder.rebuildNodeGypModule (/Users/adam/code/codex/codex/apps/electron/node_modules/electron-rebuild/lib/src/module-rebuilder.js:98:9)
    at async ModuleRebuilder.rebuild (/Users/adam/code/codex/codex/apps/electron/node_modules/electron-rebuild/lib/src/module-rebuilder.js:128:14)
    at async Rebuilder.rebuildModuleAt (/Users/adam/code/codex/codex/apps/electron/node_modules/electron-rebuild/lib/src/rebuild.js:149:13)
    at async Rebuilder.rebuild (/Users/adam/code/codex/codex/apps/electron/node_modules/electron-rebuild/lib/src/rebuild.js:112:17)
    at async /Users/adam/code/codex/codex/apps/electron/node_modules/@electron-forge/core/dist/util/rebuild.js:30:9

From the logs it looks like electron-rebuild isn't able to find the universal binary that leveldown ships for darwin. That file is at leveldown/prebuilds/darwin-x64+arm64/node.napi.node, while electron-rebuild expects leveldown/prebuilds/darwin-x64/node.napi.node.

The good news is, unless you want to build leveldown from source, you don't need electron-rebuild. Check if there's a way to disable that step in Electron Forge, e.g. via electronRebuildConfig.

If you do want to build from source, then Level/leveldown#801 is getting in your way.