wilix-team / iohook

Node.js global keyboard and mouse listener.
https://wilix-team.github.io/iohook
MIT License
1.18k stars 290 forks source link

Build for M1 fails (no rules to make target) #400

Closed nmilev-scribe closed 2 years ago

nmilev-scribe commented 2 years ago

Expected Behavior

Navigating into node_modules/iohook, running npm install and then npm run build builds iohook for the arm64 platform

Current Behavior

The npm install command passes with the following output:

nikolamilev@MacBook-Pro iohook % npm install
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated docsearch.js@2.6.3: This package has been deprecated and is no longer maintained. Please use @docsearch/js.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated highlight.js@9.18.5: Support has ended for 9.x series. Upgrade to @latest
npm WARN deprecated mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)

> iohook@0.9.3 install
> node install.js

electron 87 win32 x64
Downloading prebuild for platform: iohook-v0.9.3-electron-v87-win32-x64
Downloading prebuild.tar.gz
[============================================>] 100.0% of 157 kB (157 kB/s)
Downloading prebuild.tar.gz
[============================================>] 100.0% of 26.8 kB (26.8 kB/s)

added 1966 packages, and audited 1967 packages in 1m

128 packages are looking for funding
  run `npm fund` for details

36 vulnerabilities (1 low, 12 moderate, 23 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

The npm run build command fails with the following output:

nikolamilev@MacBook-Pro iohook % npm run build

> iohook@0.9.3 build
> node build.js --upload=false

Building iohook for electron v12.0.0>>>>
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@16.14.2 | darwin | arm64
gyp info find Python using Python version 3.9.12 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
gyp http GET https://atom.io/download/electron/v12.0.0/node-v12.0.0-headers.tar.gz
gyp http 200 https://atom.io/download/electron/v12.0.0/node-v12.0.0-headers.tar.gz
gyp http GET https://atom.io/download/electron/v12.0.0/SHASUMS256.txt
gyp http 200 https://atom.io/download/electron/v12.0.0/SHASUMS256.txt
(node:99473) [DEP0150] 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 /opt/homebrew/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/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/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nikolamilev/Library/Caches/node-gyp/12.0.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/nikolamilev/Library/Caches/node-gyp/12.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/nikolamilev/Library/Caches/node-gyp/12.0.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook',
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 info find Python using Python version 3.9.12 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/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/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/nikolamilev/Library/Caches/node-gyp/12.0.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/nikolamilev/Library/Caches/node-gyp/12.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/nikolamilev/Library/Caches/node-gyp/12.0.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook',
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 info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: *** No rule to make target `Release/obj.target/uiohook/libuiohook/src/logger.o', needed by `Release/uiohook.dylib'.  Stop.
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/node_modules/.bin/node-gyp" "configure" "rebuild" "--target=12.0.0" "--arch=arm64" "--dist-url=https://atom.io/download/electron" "--v8_enable_pointer_compression=0" "--v8_enable_31bit_smis_on_64bit_arch=1" "--build_v8_with_gn=false" "--enable_lto=false"
gyp ERR! cwd /Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook
gyp ERR! node -v v16.14.2
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
Error: Failed to build...
    at ChildProcess.<anonymous> (/Users/nikolamilev/projects/colony/platform/parrot-editor/node_modules/iohook/build.js:188:23)
    at ChildProcess.emit (node:events:526:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

Trying with yarn produced the same results.

Possible Solution

Steps to Reproduce (for bugs)

Context

Trying to run a development version of our Electron app is not possible on M1.

Your Environment

marcelblum commented 2 years ago

The manual build instructions are a bit misleading, see #380. You need to make sure to clone the whole iohook repo not just npm install it otherwise you won't have all the needed build assets, you need the contents of the iohook/libuiohook folder.

Also, I believe you'll need to specify the Electron version and ABI with the build command, I don't think you can rely on it autodetecting an unofficially supported target (note in your quoted output it says Building iohook for electron v12.0.0, not sure where it's getting v12 from). If you're targeting Electron 18 then it would be node build.js --runtime electron --version 18.0.4 --abi 103 --upload=false

I've successfully built iohook for darwin arm64 for Electron 13 but I haven't tried later Electron versions so I can't guarantee it will work 🤷‍♂️

jove0610 commented 2 years ago

Since you're using electron 18, you may want to clone PR #363 instead.

nmilev-scribe commented 2 years ago

@jove0610 It turns out I am using electron 12, but thanks. @marcelblum I followed your help and managed to build. Needed to copy the build dir into iohook directory inside node_modules, but it all works great. Thanks for the help!

I read somewhere that the docs can be improved, and I absolutely agree. Other than that, it was quick and painless.

nmilev-scribe commented 2 years ago

Since I solved my issue, closing this.

Sanjeev900 commented 2 years ago

@nmilev-scribe How did you solve it on m1 mac? Can you plz explain it step by step?