electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.61k stars 1.74k forks source link

While building an application with electron-builder, the cpu-features command fails in some environments and succeeds. #8200

Closed TakamiChie closed 4 months ago

TakamiChie commented 5 months ago

In a project that was very well built until yesterday, I got an error when I ran the command "electron-builder --mac --universal".

However, for the sake of verification, I created a repository with the minimum configuration for building on a Mac in an Electron application template, and cloned it on the same Mac machine. https://github.com/TakamiChie/electronapp-mac-test Here, when I executed the "electron-builder --mac --universal" command in the same way, I succeeded in building the application.

In such a case, what could cause the following error to appear? Note that #8081 was checked from the existing problem list, and "npx node-gyp rebuild" was executed. However, the situation has not improved.

> productname@3.1.0 npx
> electron-builder --mac --universal

  • electron-builder  version=24.13.3 os=23.4.0
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=cpu-features@0.0.9 platform=darwin arch=x64
  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm error code 1
    npm error path /Users/takamichie/Documents/GitHub/product_dir/node_modules/cpu-features
    npm error command failed
    npm error command sh -c node buildcheck.js > buildcheck.gypi && node-gyp rebuild
    npm error CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_linux_or_android.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_arm_linux_or_android.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_mips_linux_or_android.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_ppc_linux.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_freebsd.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_linux_or_android.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_macos.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_windows.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/filesystem.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/stack_line_reader.o
    npm error   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/string_view.o
    npm error   LIBTOOL-STATIC Release/cpu_features.a
    npm error   CXX(target) Release/obj.target/cpufeatures/src/binding.o
    npm error gyp info it worked if it ends with ok
    npm error gyp info using node-gyp@9.4.1
    npm error gyp info using node@21.7.1 | darwin | arm64
    npm error gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
    npm error gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
    npm error gyp info spawn args [
    npm error gyp info spawn args   '/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp/gyp/gyp_main.py',
    npm error gyp info spawn args   'binding.gyp',
    npm error gyp info spawn args   '-f',
    npm error gyp info spawn args   'make',
    npm error gyp info spawn args   '-I',
    npm error gyp info spawn args   '/Users/takamichie/Documents/GitHub/product_dir/node_modules/cpu-features/build/config.gypi',
    npm error gyp info spawn args   '-I',
    npm error gyp info spawn args   '/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp/addon.gypi',
    npm error gyp info spawn args   '-I',
    npm error gyp info spawn args   '/Users/takamichie/.electron-gyp/30.0.2/include/node/common.gypi',
    npm error gyp info spawn args   '-Dlibrary=shared_library',
    npm error gyp info spawn args   '-Dvisibility=default',
    npm error gyp info spawn args   '-Dnode_root_dir=/Users/takamichie/.electron-gyp/30.0.2',
    npm error gyp info spawn args   '-Dnode_gyp_dir=/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp',
    npm error gyp info spawn args   '-Dnode_lib_file=/Users/takamichie/.electron-gyp/30.0.2/<(target_arch)/node.lib',
    npm error gyp info spawn args   '-Dmodule_root_dir=/Users/takamichie/Documents/GitHub/product_dir/node_modules/cpu-features',
    npm error gyp info spawn args   '-Dnode_engine=v8',
    npm error gyp info spawn args   '--depth=.',
    npm error gyp info spawn args   '--no-parallel',
    npm error gyp info spawn args   '--generator-output',
    npm error gyp info spawn args   'build',
    npm error gyp info spawn args   '-Goutput_dir=.'
    npm error gyp info spawn args ]
    npm error gyp info spawn make
    npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    npm error In file included from ../src/binding.cc:3:
    npm error ../../nan/nan.h:2548:8: error: no matching member function for call to 'SetAccessor'
    npm error   tpl->SetAccessor(
    npm error   ~~~~~^~~~~~~~~~~
    npm error /Users/takamichie/.electron-gyp/30.0.2/include/node/v8-template.h:1055:8: note: candidate function not viable: no known conversion from 'v8::AccessControl' to 'PropertyAttribute' for 5th argument
    npm error   void SetAccessor(
    npm error        ^
    npm error /Users/takamichie/.electron-gyp/30.0.2/include/node/v8-template.h:1049:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'AccessorGetterCallback' (aka 'void (*)(Local<String>, const PropertyCallbackInfo<Value> &)') for 2nd argument
    npm error   void SetAccessor(
    npm error        ^
    npm error In file included from ../src/binding.cc:3:
    npm error ../../nan/nan.h:2594:8: error: no matching member function for call to 'SetAccessor'
    npm error   tpl->SetAccessor(
    npm error   ~~~~~^~~~~~~~~~~
    npm error /Users/takamichie/.electron-gyp/30.0.2/include/node/v8-template.h:1055:8: note: candidate function not viable: no known conversion from 'v8::AccessControl' to 'PropertyAttribute' for 5th argument
    npm error   void SetAccessor(
    npm error        ^
    npm error /Users/takamichie/.electron-gyp/30.0.2/include/node/v8-template.h:1049:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'AccessorGetterCallback' (aka 'void (*)(Local<String>, const PropertyCallbackInfo<Value> &)') for 2nd argument
    npm error   void SetAccessor(
    npm error        ^
    npm error 2 errors generated.
    npm error make: *** [Release/obj.target/cpufeatures/src/binding.o] Error 1
    npm error gyp ERR! build error 
    npm error gyp ERR! stack Error: `make` failed with exit code: 2
    npm error gyp ERR! stack     at ChildProcess.onExit (/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp/lib/build.js:203:23)
    npm error gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
    npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
    npm error gyp ERR! System Darwin 23.4.0
    npm error gyp ERR! command "/opt/homebrew/Cellar/node/21.7.1/bin/node" "/Users/takamichie/Documents/GitHub/product_dir/node_modules/.bin/node-gyp" "rebuild"
    npm error gyp ERR! cwd /Users/takamichie/Documents/GitHub/product_dir/node_modules/cpu-features
    npm error gyp ERR! node -v v21.7.1
    npm error gyp ERR! node-gyp -v v9.4.1
    npm error gyp ERR! not ok

    npm error A complete log of this run can be found in: /Users/takamichie/.npm/_logs/2024-05-04T11_07_57_142Z-debug-0.log

                    command=/opt/homebrew/Cellar/node/21.7.1/bin/node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js rebuild cpu-features@0.0.9
                    workingDir=

The error log when the "npx node-gyp rebuild" command is executed is also attached below.

> productname@3.1.0 npx
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.1
gyp info using node@21.7.1 | darwin | arm64
gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/Users/takamichie/Documents/GitHub/product_dir/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/takamichie/Documents/GitHub/product_dir/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/takamichie/Library/Caches/node-gyp/21.7.1/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/takamichie/Library/Caches/node-gyp/21.7.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/takamichie/Library/Caches/node-gyp/21.7.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/takamichie/Documents/GitHub/product_dir',
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 ]
gyp: binding.gyp not found (cwd: /Users/takamichie/Documents/GitHub/product_dir) while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/takamichie/Documents/GitHub/product_dir/node_modules/node-gyp/lib/configure.js:325:16)
gyp ERR! stack     at ChildProcess.emit (node:events:519:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Darwin 23.4.0
gyp ERR! command "/opt/homebrew/Cellar/node/21.7.1/bin/node" "/Users/takamichie/Documents/GitHub/product_dir/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/takamichie/Documents/GitHub/product_dir
gyp ERR! node -v v21.7.1
gyp ERR! node-gyp -v v9.4.1
gyp ERR! not ok 
TakamiChie commented 4 months ago

For this issue, I would like you to withdraw the issue because the error is no longer reproducible.