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.59k stars 1.73k forks source link

Install App Deps are failing when searching for dependency canvas #7698

Closed aravindjaimon closed 9 months ago

aravindjaimon commented 1 year ago

After npm i the post install script executes, which installs the electron-builder dependencies(exitzero electron-builder install-app-deps). This one is failing when trying to install its dependency canvas.

> exitzero electron-builder install-app-deps

  • electron-builder  version=23.6.0
  • rebuilding native dependencies  dependencies=canvas@2.11.2, keytar@7.9.0 platform=linux arch=x64
  • install prebuilt binary  name=keytar version=7.9.0 platform=linux arch=x64 napi=
                                                                                      ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path /project/node_modules/canvas
    npm ERR! command failed
    npm ERR! command sh -c -- node-pre-gyp install --fallback-to-build --update-binary
    npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/project/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/project/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v21.4' (1)
    npm ERR! node-pre-gyp info it worked if it ends with ok
    npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10
    npm ERR! node-pre-gyp info using node@16.20.0 | linux | x64
    npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-electron-v21.4-linux-glibc-x64.tar.gz
    npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-electron-v21.4-linux-glibc-x64.tar.gz 
    npm ERR! node-pre-gyp WARN Pre-built binaries not installable for canvas@2.11.2 and electron@21.4.2 (electron-v21.4 ABI, glibc) (falling back to source compile with node-gyp) 
    npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-electron-v21.4-linux-glibc-x64.tar.gz 
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@9.1.0
    npm ERR! gyp info using node@16.20.0 | linux | x64
    npm ERR! gyp info ok 
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@9.1.0
    npm ERR! gyp info using node@16.20.0 | linux | x64
    npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
    npm ERR! gyp http GET https://electronjs.org/headers/v21.4.2/node-v21.4.2-headers.tar.gz
    npm ERR! gyp http 200 https://artifacts.electronjs.org/headers/v21.4.2/node-v21.4.2-headers.tar.gz?force_headers_dist=1
    npm ERR! gyp http GET https://electronjs.org/headers/v21.4.2/SHASUMS256.txt
    npm ERR! gyp http 200 https://artifacts.electronjs.org/headers/v21.4.2/SHASUMS256.txt?force_headers_dist=1
    npm ERR! gyp info spawn /usr/bin/python3
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    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   '/project/node_modules/canvas/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/root/.electron-gyp/21.4.2/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=/root/.electron-gyp/21.4.2',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.electron-gyp/21.4.2/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/project/node_modules/canvas',
    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! Package pixman-1 was not found in the pkg-config search path.
    npm ERR! Perhaps you should add the directory containing `pixman-1.pc'
    npm ERR! to the PKG_CONFIG_PATH environment variable
    npm ERR! No package 'pixman-1' found
    npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
    npm ERR! gyp ERR! configure error 
    npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:284:16)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
    npm ERR! gyp ERR! System Linux 6.4.6-1-MANJARO
    npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/project/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/project/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v21.4"
    npm ERR! gyp ERR! cwd /project/node_modules/canvas
    npm ERR! gyp ERR! node -v v16.20.0
    npm ERR! gyp ERR! node-gyp -v v9.1.0
    npm ERR! gyp ERR! not ok 
    npm ERR! node-pre-gyp ERR! build error 
    npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/project/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/project/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v21.4' (1)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/project/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
    npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
    npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
    npm ERR! node-pre-gyp ERR! System Linux 6.4.6-1-MANJARO
    npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/project/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary"
    npm ERR! node-pre-gyp ERR! cwd /project/node_modules/canvas
    npm ERR! node-pre-gyp ERR! node -v v16.20.0
    npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10
    npm ERR! node-pre-gyp ERR! not ok

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2023-07-28T11_52_40_986Z-debug-0.log

                    command=/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js rebuild canvas@2.11.2
                    workingDir=

As you can see from the error log, It is searching for a canvas from https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-electron-v21.4-linux-glibc-x64.tar.gz but that doesnt exist. The canvas that exist is in the vesion of node, but its searching for an electron version of node.

Not sure how to solve it. Any suggestions.

When I try normal npm i its working fine, but when building the app in electron-builder container, and in wine and also in mac, its failing.

mmaietta commented 1 year ago

I don't think electron-builder can control this? It looks like node-pre-gyp is fully in control of what is being downloaded, right?

What happens if you force buildDependenciesFromSource: true?

aravindjaimon commented 1 year ago

@mmaietta Tried that just now, But the issue is persisting.

mmaietta commented 1 year ago

I took a look at the source code for the Golang dependency electron-builder uses for handling native modules. If prebuilds are not available, the only way for buildDependenciesFromSource to work is by building the .node binary on each source platform (can't use wine IIRC), otherwise it'll continue forward with attempting installing a prebuilt binary.

The Golang dependency short circuits the prebuild logic if it receivesBuildFromSource: true and isRebuildPossible := checkRebuildPossible(configuration) === true

If that still isn't working, which I can't imagine why it wouldn't, then I'm afraid you may be out of luck. Basically, if you're seeing Installing prebuilt binary in the electron-builder logs, something is wrong with your configuration.

https://github.com/electron-userland/electron-builder/blob/ef4e8d9824e51b3c9e18fbaf5b1136a6479c82df/packages/app-builder-lib/src/util/yarn.ts#L10-L15 https://github.com/develar/app-builder/blob/4e2aa6a12e2bc3d31ec0d01d661fb3a4d65248ff/pkg/node-modules/rebuild.go#L177-L182

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 9 months ago

This issue was closed because it has been stalled for 30 days with no activity.

kotasudhakar commented 6 months ago

This is still happening, was anyone able to fix this?

mmaietta commented 6 months ago

Can you try using next version 25.0.0-alpha.5. It now uses the official electron/rebuild package by default, which might resolve this error?

kotasudhakar commented 6 months ago

Tried with the 25.0.0-alpha.5 version didnt work, here is the log

$ npm i

proj-zerolens@11.1.1 postinstall electron-builder install-app-deps

• electron-builder version=25.0.0-alpha.5 • loaded configuration file=package.json ("build" field) • executing @electron/rebuild electronVersion=28.2.2 arch=x64 buildFromSource=false appDir=./ • installing native dependencies arch=x64 • preparing moduleName=canvas arch=x64 ⨯ Backend.cc D:\work\project\node_modules\nan\nan.h(688,37): warning C4996: 'v8::Isolate::IdleNotificationDeadline': Use MemoryPressureNotification() to influence the GC schedule. [D:\work\project\node_modules\canvas\build\canvas.vcxproj] (compiling source file '../src/backend/Backend.cc')

D:\work\project\node_modules\nan\nan.h(2548,6): error C2665: 'v8::ObjectTemplate::SetAccessor': no overloaded function could convert all the argument types [D:\work\project\node_modules\canvas\build\canvas.vcxproj] (compiling source file '../src/backend/Backend.cc') C:\Users\proj.electron-gyp\28.2.2\include\node\v8-template.h(816,8): could be 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorNameGetterCallback,v8::AccessorNameSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)' D:\work\project\node_modules\nan\nan.h(2548,6): 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorNameGetterCallback,v8::AccessorNameSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)': cannot convert argument 5 from 'v8::PropertyAttribute' to 'v8::AccessControl' D:\work\project\node_modules\nan\nan.h(2556,7): Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast) C:\Users\proj.electron-gyp\28.2.2\include\node\v8-template.h(809,8): or 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorGetterCallback,v8::AccessorSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)' D:\work\project\node_modules\nan\nan.h(2548,6): 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorGetterCallback,v8::AccessorSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)': cannot convert argument 2 from 'Nan::imp::NativeGetter' to 'v8::AccessorGetterCallback' D:\work\project\node_modules\nan\nan.h(2550,7): This conversion requires a reinterpret_cast, a C-style cast or parenthesized function-style cast D:\work\project\node_modules\nan\nan.h(2548,6): while trying to match the argument list '(v8::Local, Nan::imp::NativeGetter, Nan::imp::NativeSetter, v8::Local, v8::PropertyAttribute)'

D:\work\project\node_modules\nan\nan.h(2596,6): error C2665: 'v8::ObjectTemplate::SetAccessor': no overloaded function could convert all the argument types [D:\work\project\node_modules\canvas\build\canvas.vcxproj] (compiling source file '../src/backend/Backend.cc') C:\Users\proj.electron-gyp\28.2.2\include\node\v8-template.h(816,8): could be 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorNameGetterCallback,v8::AccessorNameSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)' D:\work\project\node_modules\nan\nan.h(2596,6): 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorNameGetterCallback,v8::AccessorNameSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)': cannot convert argument 5 from 'v8::PropertyAttribute' to 'v8::AccessControl' D:\work\project\node_modules\nan\nan.h(2604,7): Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast) C:\Users\proj.electron-gyp\28.2.2\include\node\v8-template.h(809,8): or 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorGetterCallback,v8::AccessorSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)' D:\work\project\node_modules\nan\nan.h(2596,6): 'void v8::ObjectTemplate::SetAccessor(v8::Local,v8::AccessorGetterCallback,v8::AccessorSetterCallback,v8::Local,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType,v8::SideEffectType)': cannot convert argument 2 from 'Nan::imp::NativeGetter' to 'v8::AccessorGetterCallback' D:\work\project\node_modules\nan\nan.h(2598,7): This conversion requires a reinterpret_cast, a C-style cast or parenthesized function-style cast D:\work\project\node_modules\nan\nan.h(2596,6): while trying to match the argument list '(v8::Local, Nan::imp::NativeGetter, Nan::imp::NativeSetter, v8::Local, v8::PropertyAttribute)'

Error: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1 at ChildProcess.onExit (D:\work\project\node_modules\node-gyp\lib\build.js:203:23) at ChildProcess.emit (node:events:517:28) at ChildProcess._handle.onexit (node:internal/child_process:292:12)

⨯ node-gyp failed to rebuild 'D:\work\project\node_modules\canvas' failedTask=installAppDeps stackTrace=Error: node-gyp failed to rebuild 'D:\work\project\node_modules\canvas' at ChildProcess. (D:\work\project\node_modules\@electron\rebuild\lib\module-type\node-gyp\node-gyp.js:118:24) at ChildProcess.emit (node:events:517:28) at ChildProcess._handle.onexit (node:internal/child_process:292:12) npm ERR! code 1 npm ERR! path D:\work\project npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c electron-builder install-app-deps

npm ERR! A complete log of this run can be found in: C:\Users\proj\AppData\Local\npm-cache_logs\2024-03-20T00_33_33_941Z-debug-0.log

mmaietta commented 6 months ago

The first error in your OP is npm ERR! Package pixman-1 was not found in the pkg-config search path.

Looks like pixman is missing from your system.

kotasudhakar commented 6 months ago

i am using windows, how i can install it

ImpChiang commented 5 months ago

@kotasudhakar i have same error,has solved it yet?

kotasudhakar commented 5 months ago

@kotasudhakar i have same error,has solved it yet?

The canvas library did not make any release until now using the new n-api, until that happens, unfortunately no way we can use the libraries using the canvas as dependancy. i switched to using pdfjs using as the directly in the src, without actually including it as the npm package

ImpChiang commented 5 months ago

ok,I got it,Thanks