modmoto
modmoto

Reputation: 3280

Signed electron app does not start with robotjs on OSX (Unhandled Errpr: no suitable image found)

I have a signed and notarized App where I want to use robotjs to simulate key taps. I had no problems building robotjs locally but when I run it through the CI, where I sign and notarize the app, the app throws the following error upon starting:

electron/js2c/asar.js:140 Uncaught Error: dlopen(/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr, 1): no suitable image found.  Did find:
    /var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr: code signature in (/var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
    /var/folders/jh/c4kr0qwj0jz2g6qr9y62v3f80000gn/T/.com.electron.w3champions-launcher.JGzZcr: stat() failed with errno=17
    at process.func [as dlopen] (electron/js2c/asar.js:140)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1034)
    at Object.func [as .node] (electron/js2c/asar.js:149)
    at Module.load (internal/modules/cjs/loader.js:815)
    at Module._load (internal/modules/cjs/loader.js:727)
    at Function.Module._load (electron/js2c/asar.js:769)
    at Module.require (internal/modules/cjs/loader.js:852)
    at require (internal/modules/cjs/helpers.js:74)
    at Object.<anonymous> (/Applications/w3champions-launcher.app/Contents/Resources/app.asar/node_modules/robotjs/index.js:1)
    at Object.<anonymous> (/Applications/w3champions-launcher.app/Contents/Resources/app.asar/node_modules/robotjs/index.js:38)

I have the feeling that I do not sign the built robotjs stuff and therefore OSX is not happy when loading it. If I remove the notarize step, I get the same error. Those are my build commands:

"build": "npm run rebuild && vue-cli-service electron:build",
"rebuild": "npm rebuild --runtime=electron --target=9.1.2 --disturl=https://atom.io/download/atom-shell --abi=80",

I found something here: https://github.com/electron-userland/electron-builder/issues/4040#issuecomment-543252275 but I lack electron knowledge to make this happen. Also he uses react and a 2 package.json solution, which I do not have. Do I have to add a sign step for robotjs and if so, how do I do that? On Windows everything is working fine, no problem in signing and building.

this would be the repo: https://github.com/w3champions/w3champions-launcher

Upvotes: 1

Views: 1079

Answers (1)

modmoto
modmoto

Reputation: 3280

Ok, i somehow stumbled over a post where something similar happened and fixed it. What I changed in my odyssey of google are the following things, maybe one of those might help someone:

In the vue.config.js I added builderOptions.mac.entitlementsInherit = "build/entitlements.mac.inherit.plist". Earlier I only had builderOptions.mac.entitlements

I added those tow entitelments to my entitelments list:

<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>

In the package.json i changed my build sightly to

"build": "npm run rebuild && vue-cli-service electron:build",
"rebuild": "npm rebuild --runtime=electron --target=9.1.2 -- disturl=https://atom.io/download/atom-shell --abi=80"

The change was mearly to make the abi the correct one. You can get the needed abi by electron --abi

Upvotes: 1

Related Questions