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

Rebuilding native dependencies don't work for Electron 20 and up #7175

Closed
oalfroukh opened this issue Oct 4, 2022 · 16 comments · Fixed by #7196
Closed

Rebuilding native dependencies don't work for Electron 20 and up #7175

oalfroukh opened this issue Oct 4, 2022 · 16 comments · Fixed by #7196

Comments

@oalfroukh
Copy link

  • Electron-Builder Version: 23.6.0
  • Node Version: 14.18.1 32-bit
  • Electron Version:20.3.0 and up
  • Electron Type (current, beta, nightly):current
  • Target: nsis
  • Rebuilding native dependencies don't work for Electron 20 and up, I added sqlite3 v4.2.0 as dependencies to prove the issue.
  • The issue doesn't exist in Electron v19.x.
  • Here is my package.json file:
{
  "name": "electron-quick-start",
  "productName": "electron-quick-start",
  "description": "My Electron application description",
  "keywords": [],
  "main": "./main.js",
  "version": "1.0.0",
  "author": "oalfroukh",
  "scripts": {
    "start": "electron .",
    "dist": "electron-builder"
  },
  "build": {
    "buildVersion": "1.0.0.0",
    "compression": "normal",
    "win": {
      "target": "nsis",
      "verifyUpdateCodeSignature": false
    },
    "nsis": {
      "oneClick": false,
      "perMachine": false,
      "allowToChangeInstallationDirectory": true,
      "differentialPackage": false
    },
    "squirrelWindows": {
      "msi": "true"
    },
    "msi": {
      "warningsAsErrors": false
    },
    "appx": {
      "publisherDisplayName": "test"
    },
    "electronVersion": "20.3.0",
    "buildDependenciesFromSource": true,
    "nodeGypRebuild": false,
    "npmRebuild": true,
    "extends": null
  },
  "dependencies": {
    "sqlite3": "4.2.0"
  },
  "devDependencies": {
    "electron": "20.3.0",
    "electron-builder": "23.6.0"
  }
}
  • Here is the error for the issue:
$ npm run dist

> electron-quick-start@1.0.0 dist C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start
> electron-builder

  • electron-builder  version=23.6.0 os=10.0.19044
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist\builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=sqlite3@4.2.0 platform=win32 arch=ia32
  ⨯ cannot execute  cause=exit status 1
                    out=
    > sqlite3@4.2.0 install C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3
    > node-pre-gyp install --fallback-to-build

    Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
      unpack_sqlite_dep
      sqlite3.c
      win_delay_load_hook.cc
      sqlite3.vcxproj -> C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\Release\\sqlite3.lib
      backup.cc
      database.cc
      node_sqlite3.cc
      statement.cc
      win_delay_load_hook.cc
    C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error:  "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\backup.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
    C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error:  "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\statement.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
    C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error:  "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\database.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
    C:\Users\oalfroukh\.electron-gyp\20.0.1\include\node\node.h(27,1): fatal error C1189: #error:  "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." (compiling source file ..\src\node_sqlite3.cc) [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
    Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v20.0' (1)

                    errorOut=node-pre-gyp WARN Using needle for node-pre-gyp https download
    gyp ERR! build error
    gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
    gyp ERR! System Windows_NT 10.0.19044
    gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\oalfroukh\\AppData\\Roaming\\nvm\\v14.18.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\oalfroukh\\Desktop\\Test projects\\electron-quick-start\\node_modules\\sqlite3\\lib\\binding\\electron-v20.0-win32-ia32\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\\Users\\oalfroukh\\Desktop\\Test projects\\electron-quick-start\\node_modules\\sqlite3\\lib\\binding\\electron-v20.0-win32-ia32" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v20.0"
    gyp ERR! cwd C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3
    gyp ERR! node -v v14.18.1
    gyp ERR! node-gyp -v v5.1.0
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\lib\binding\electron-v20.0-win32-ia32 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v20.0' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
    node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
    node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1058:16)
    node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
    node-pre-gyp ERR! System Windows_NT 10.0.19044
    node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\oalfroukh\\Desktop\\Test projects\\electron-quick-start\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3
    node-pre-gyp ERR! node -v v14.18.1
    node-pre-gyp ERR! node-pre-gyp -v v0.11.0
    node-pre-gyp ERR! not ok
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! sqlite3@4.2.0 install: `node-pre-gyp install --fallback-to-build`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the sqlite3@4.2.0 install 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!     C:\Users\oalfroukh\AppData\Roaming\npm-cache\_logs\2022-10-04T15_08_47_130Z-debug.log

                    command='C:\Program Files\nodejs\node.exe' 'C:\Users\oalfroukh\AppData\Roaming\nvm\v14.18.1\node_modules\npm\bin\npm-cli.js' rebuild sqlite3@4.2.0
                    workingDir=
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-quick-start@1.0.0 dist: `electron-builder`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-quick-start@1.0.0 dist 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!     C:\Users\oalfroukh\AppData\Roaming\npm-cache\_logs\2022-10-04T15_08_47_205Z-debug.log
<!-- If you want, you can donate to increase issue priority (https://www.electron.build/donate) -->
@themastersoda
Copy link

themastersoda commented Oct 6, 2022

I seem to be having the same issue when upgrading from electron 19 to 20. Rebuilding native modules fails due to c++17 not being used, but it seems that there's no option to pass such flags to node-gyp through electron-builder:

$ electron-builder install-app-deps
  • electron-builder  version=23.6.0
  • rebuilding native dependencies  dependencies=@nodert-win10-rs4/[email protected], [email protected] platform=win32 arch=x64
  • install prebuilt binary  name=keytar version=7.9.0 platform=win32 arch=x64 napi= 
  • rebuilding native dependency  name=@nodert-win10-rs4/windows.security.credentials.ui version=0.4.4
  ⨯ cannot execute  cause=exit status 1
                    out=$ node-gyp rebuild
    
    C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild ) 
    Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
      _nodert_generated.cpp
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-internal.h(471,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-internal.h(472,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-internal.h(655,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-internal.h(656,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-internal.h(657,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-isolate.h(1531,45): warning C4996: 'v8::WasmDynamicTieringEnabledCallback': Dynamic tiering is now enabled by default [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\v8-wasm.h(192,34): warning C4996: 'v8::WasmStreaming::Client': Use SetMoreFunctionsCanBeSerializedCallback [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    C:\Users\gitlab-runner\.electron-gyp\21.1.0\include\node\node.h(27,1): fatal error C1189: #error:  "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." [C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\build\binding.vcxproj]
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    
                    errorOut=gyp info it worked if it ends with ok
    gyp info using [email protected]
    gyp info using [email protected] | win32 | x64
    gyp info find Python using Python version 3.7.9 found at "C:\Program Files\Python37\python.exe"
    gyp http GET https://electronjs.org/headers/v21.1.0/node-v21.1.0-headers.tar.gz
    gyp http 200 https://electronjs.org/headers/v21.1.0/node-v21.1.0-headers.tar.gz
    gyp http GET https://electronjs.org/headers/v21.1.0/SHASUMS256.txt
    gyp http GET https://electronjs.org/headers/v21.1.0/win-x86/node.lib
    gyp http GET https://electronjs.org/headers/v21.1.0/win-arm64/node.lib
    gyp http GET https://electronjs.org/headers/v21.1.0/win-x64/node.lib
    gyp http 200 https://electronjs.org/headers/v21.1.0/SHASUMS256.txt
    gyp http 200 https://electronjs.org/headers/v21.1.0/win-x64/node.lib
    gyp http 200 https://electronjs.org/headers/v21.1.0/win-x86/node.lib
    gyp http 200 https://electronjs.org/headers/v21.1.0/win-arm64/node.lib
    gyp info find VS using VS2019 (16.11.31727.386) found at:
    gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
    gyp info find VS run with --verbose for detailed information
    (node:5508) [DEP0[150](https://bucket.digitalarsenal.net/<user>/desktop-app/-/jobs/4796052#L150)] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
    (Use `node --trace-deprecation ...` to show where the warning was created)
    gyp info spawn C:\Program Files\Python37\python.exe
    gyp info spawn args [
    gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'msvs',
    gyp info spawn args   '-I',
    gyp info spawn args   'C:\\GitLab-Runner\\builds\\XbXLaCtk\\0\\<user>\\desktop-app\\node_modules\\@nodert-win10-rs4\\windows.security.credentials.ui\\build\\config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   'C:\\GitLab-Runner\\builds\\XbXLaCtk\\0\\<user>\\desktop-app\\node_modules\\@nodert-win10-rs4\\windows.security.credentials.ui\\common.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   'C:\\Users\\gitlab-runner\\.electron-gyp\\21.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=C:\\Users\\gitlab-runner\\.electron-gyp\\21.1.0',
    gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
    gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\gitlab-runner\\\\.electron-gyp\\\\21.1.0\\\\<(target_arch)\\\\node.lib',
    gyp info spawn args   '-Dmodule_root_dir=C:\\GitLab-Runner\\builds\\XbXLaCtk\\0\\<user>\\desktop-app\\node_modules\\@nodert-win10-rs4\\windows.security.credentials.ui',
    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   'C:\\GitLab-Runner\\builds\\XbXLaCtk\\0\\<user>\\desktop-app\\node_modules\\@nodert-win10-rs4\\windows.security.credentials.ui\\build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe
    gyp info spawn args [
    gyp info spawn args   'build/binding.sln',
    gyp info spawn args   '/clp:Verbosity=minimal',
    gyp info spawn args   '/nologo',
    gyp info spawn args   '/p:Configuration=Release;Platform=x64'
    gyp info spawn args ]
    gyp ERR! build error 
    gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
    gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
    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:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui
    gyp ERR! node -v v16.10.0
    gyp ERR! node-gyp -v v7.1.2
    gyp ERR! not ok 
    error Command failed with exit code 1.
    
                    command='C:\Program Files\nodejs\node.exe' 'C:\Program Files (x86)\Yarn\bin\yarn.js' run install
                    workingDir=C:\GitLab-Runner\builds\XbXLaCtk\0\<user>\desktop-app\node_modules\@nodert-win10-rs4\windows.security.credentials.ui
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "builder install-app-deps" exited with 1.
error Command failed with exit code 1.

@mmaietta
Copy link
Collaborator

mmaietta commented Oct 6, 2022

Hmmm, can you try setting it via env vars? I see the gyp env allowing that as args

export function getGypEnv(frameworkInfo: DesktopFrameworkInfo, platform: NodeJS.Platform, arch: string, buildFromSource: boolean) {
const npmConfigArch = arch === "armv7l" ? "arm" : arch
const common: any = {
...process.env,
npm_config_arch: npmConfigArch,
npm_config_target_arch: npmConfigArch,
npm_config_platform: platform,
npm_config_build_from_source: buildFromSource,
// required for node-pre-gyp
npm_config_target_platform: platform,
npm_config_update_binary: true,
npm_config_fallback_to_build: true,
}

@themastersoda
Copy link

Hmm, I'm either not seeing the option to configure it or it does not appear to be configurable via env vars. Which variable exactly do you mean? I suppose it would have to be this option:
nodejs/node-gyp#1662 (comment)

@michalzaq12
Copy link

I think it should be handled internally, same as in the electron-rebuild package (electron/rebuild@6f94aaa), if the electron version is >= 20.
Additionally, on Windows, it probably cannot be done with the help of environment variables.
How to set the std:c++17 flag depending on the platform: electron/electron#33906 (comment)

@mmaietta
Copy link
Collaborator

So, AFAICT, I can't do that within electron-builder, as the native dependency rebuild seems to be handled by Go-library app-builder(-bin).

That being said, what I would like to do in the next major version bump of electron-builder is to migrate it to use electron-rebuild. "Install production dependencies" would function the same with it's conditional npm/yarn install logic, but anything involving app-builder-bin/node-gyp w.r.t. native dependencies would be passed through to electron-rebuild directly

One thing we're dependent upon is electron/rebuild#989 for buildDependenciesFromSource, otherwise I can't make a clean migration over. There's some other finicky aspects of electron-rebuild, mostly due to node-gyp/make verbose output that app-builder swallows AFAICT. electron-rebuild isn't able to discern external vs project native modules (the Go-library does -> install-app-deps versus node-gyp-rebuild), so electron-rebuild just rebuilds all of them (i.e. both commands have the same effect if prod node_modules are already present)

Seems like a minor nuisance with great benefit since we'd be migrating to an official electron package.

For the interim folks, I think a workaround is to use the electron-rebuild package directly in the beforeBuild hook. (I actually have this setup already in a personal project)

import { rebuild } from 'electron-rebuild';

// ...in electron-builder config object...
nodeGypRebuild: false,
buildDependenciesFromSource: false,
beforeBuild: async (context) => {
    const { appDir, electronVersion, arch } = context
    await rebuild({ buildPath: appDir, electronVersion, arch, debug: false })
    return false
},

@mmaietta mmaietta self-assigned this Oct 12, 2022
@namespace-github
Copy link

namespace-github commented Oct 17, 2022

I solved the problem in my own native node modules by defining the following setting in the binding.gyp:

      "msvs_settings": {
        "VCCLCompilerTool": { "AdditionalOptions": ["/std:c++17" ] }
      }

... additionally i defined a custom install script that rebuilds to a specific electron-version:

    "manual-rebuild": "node-gyp rebuild --target=21.1.1 --arch=x64 --dist-url=https://electronjs.org/headers",
    "install": "npm run manual-rebuild",

together with "nodeGypRebuild": false

(I also support to be able to specify the VCCL-Compiler via the electron builder)

@oalfroukh
Copy link
Author

I solved the problem in my own native node modules by defining the following setting in the binding.gyp:

      "msvs_settings": {
        "VCCLCompilerTool": { "AdditionalOptions": ["/std:c++17" ] }
      }

... additionally i defined a custom install script that rebuilds to a specific electron-version:

    "manual-rebuild": "node-gyp rebuild --target=21.1.1 --arch=x64 --dist-url=https://electronjs.org/headers",
    "install": "npm run manual-rebuild",

together with "nodeGypRebuild": false

(I also support to be able to specify the VCCL-Compiler via the electron builder)

OK, but this is not a solution for the native dependencies which on npm and we have no control over it, so electron-builder should handle the case.

@mmaietta
Copy link
Collaborator

Quick update: Release 24.0.0-alpha.1 is the migration to electron-rebuild so you don't need the workaround. Please give it a shot (just note the breaking changes 🙂)

@ludvigintel
Copy link

Quick update: Release 24.0.0-alpha.1 is the migration to electron-rebuild so you don't need the workaround. Please give it a shot (just note the breaking changes 🙂)

I'm using Electron 21.2.0 and electron-builder 24.0.0-alpha.1 but it still doesn't seem to work :/

@carterbs
Copy link

Tried Electron 21.0.1 and electron-builder 24.0.0-alpha.2 on macos and it's still failing. Currently trying to redo our build to use the workaround you suggested @mmaietta

@koji
Copy link

koji commented Oct 27, 2022

We are using v21.1.0 and 24.0.0-alpha.1 and it's working on GitHub Actions(macOS-latest, Windows-2022, and Ubuntu-22.04)
Thank you, @mmaietta!

@carterbs
Copy link

carterbs commented Oct 27, 2022

Versions:
Electron 21.1.0
Electron-builder 24.0.0-alpha.2
Electron-rebuild: 3.2.9

Condensed errors:

npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   REDACTED
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   REDACTED
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args  REDACTED
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/brad.carter/.electron-gyp/21.1.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/brad.carter/.electron-gyp/21.1.0',
npm ERR! gyp info spawn args   REDACTED
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/brad.carter/.electron-gyp/21.1.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   REDACTED
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/keymapping.cc:6:
npm ERR! In file included from /Users/brad.carter/.electron-gyp/21.1.0/include/node/node.h:69:
npm ERR! In file included from /Users/brad.carter/.electron-gyp/21.1.0/include/node/v8.h:24:
npm ERR! In file included from /Users/brad.carter/.electron-gyp/21.1.0/include/node/v8-array-buffer.h:12:
npm ERR! In file included from /Users/brad.carter/.electron-gyp/21.1.0/include/node/v8-local-handle.h:12:
npm ERR! /Users/brad.carter/.electron-gyp/21.1.0/include/node/v8-internal.h:471:30: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions]
npm ERR! SHARED_EXTERNAL_POINTER_TAGS(CHECK_SHARED_EXTERNAL_POINTER_TAGS)

Many more wc++17 warnings. Same issue on 24.0.0-alpha.1. Trying to track it down. Doesn't happen with the same native dep in electron quickstart, so it must be some kind of config gone awry.

@oalfroukh
Copy link
Author

Hi @mmaietta
Still there is an issue in /std:c++17 seems Electron rebuild doesn't handle it already there is a reported issue to Electron rebuild, or shall you handle it from Electron-builder itself?

Thanks for your help!

 • executing electron-rebuild  appDir=C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start arch=x64
  • loaded configuration  file=package.json ("build" field)
Attempting to build a module with a space in the path
See https://github.com/nodejs/node-gyp/issues/65#issuecomment-368820565 for reasons why this may not work
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  unpack_sqlite_dep
  sqlite3.c
  win_delay_load_hook.cc
  sqlite3.vcxproj -> C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\Release\\sqlite3.lib
  backup.cc
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-internal.h(471,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' 
[C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-internal.h(472,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' 
[C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-internal.h(655,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' 
[C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-internal.h(656,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' 
[C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-internal.h(657,1): error C2429: language feature 'terse static assert' requires compiler flag '/std:c++17' 
[C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-isolate.h(1531,45): warning C4996: 'v8::WasmDynamicTieringEnabledCallback': Dynamic tiering is now enabled 
by default [C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\.electron-gyp\21.0.0\include\node\v8-wasm.h(192,34): warning C4996: 'v8::WasmStreaming::Client': Use SetMoreFunctionsCanBeSerializedCallback [C:
\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\oalfroukh\Desktop\Test projects\electron-quick-start\node_modules\sqlite3\src\backup.cc(105,17): warning C4996: 'Nan::MakeCallback': was declared deprecat

@ludvigintel
Copy link

I get the same error as @oalfroukh

@mmaietta
Copy link
Collaborator

If the error still exists, per electron/electron#35869, then there's nothing electron-builder can do to fix that. We use electron-rebuild upstream now in order to properly track electron changes.

If you'd like to propose maintaining an upstream Go-library, app-builder-bin https://github.com/develar/app-builder, then you're welcome to contribute there such that it parses dependencies correctly and applies the right c++ flags.

@oalfroukh
Copy link
Author

Thanks @mmaietta the issue is fixed from Electron side electron/electron#36383 in the latest versions (v21.3.1 and 20.3.7)

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

Successfully merging a pull request may close this issue.

8 participants