Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Issue Building Keytar on M1 Mac #406

Open
1 task
xkenneth opened this issue Aug 7, 2021 · 7 comments
Open
1 task

Issue Building Keytar on M1 Mac #406

xkenneth opened this issue Aug 7, 2021 · 7 comments

Comments

@xkenneth
Copy link

xkenneth commented Aug 7, 2021

Prerequisites

I could not access the message board. I read through these pre-reqs and they seem more relevant to Atom as a text editor than just to Keytar as a module.

Description

Steps to Reproduce

  1. Add KeyTar to a project with Electron, Webkit, Typescript, etc.

Expected behavior:

I would expect key tar to build and run when installed through NPM/yarn.

Actual behavior:

Some cryptic build error is produced that I am struggling to find out how to get around.

xkenneth@Bandley-M1 decode-lake-stats % yarn start yarn run v1.22.10 $ electron-forge start ✔ Checking your system ✔ Locating Application ⠦ Preparing native dependencies: 0 / 1gyp info find Python using Python version 2.7.16 found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python" ⠧ Preparing native dependencies: 0 / 1(node:685) [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 /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args '/Users/xkenneth/Work/electron/decode-lake-stats/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/xkenneth/Work/electron/decode-lake-stats/node_modules/keytar/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/xkenneth/.electron-gyp/13.1.7/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/xkenneth/.electron-gyp/13.1.7',
gyp info spawn args '-Dnode_gyp_dir=/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/xkenneth/.electron-gyp/13.1.7/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/keytar',
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 ]
⠇ Preparing native dependencies: 0 / 1gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/keytar/src/async.o
⠹ Preparing native dependencies: 0 / 1In file included from ../src/async.cc:4:
In file included from ../../node-addon-api/napi.h:2725:
../../node-addon-api/napi-inl.h:1393:24: error: use of undeclared identifier 'napi_object_freeze'
napi_status status = napi_object_freeze(_env, _value);
^
../../node-addon-api/napi-inl.h:1399:24: error: use of undeclared identifier 'napi_object_seal'
napi_status status = napi_object_seal(_env, _value);
^
⠸ Preparing native dependencies: 0 / 12 errors generated.
make: *** [Release/obj.target/keytar/src/async.o] Error 1
✖ Preparing native dependencies: 0 / 1

An unhandled error has occurred inside Forge:
node-gyp failed to rebuild '/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/keytar'.
Error: make failed with exit code: 2

Error: node-gyp failed to rebuild '/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/keytar'.
Error: make failed with exit code: 2

at ModuleRebuilder.rebuildNodeGypModule (/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/electron-rebuild/src/module-rebuilder.ts:231:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Rebuilder.rebuildModuleAt (/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/electron-rebuild/src/rebuild.ts:283:5)
at Rebuilder.rebuild (/Users/xkenneth/Work/electron/decode-lake-stats/node_modules/electron-rebuild/src/rebuild.ts:189:9)
at /Users/xkenneth/Work/electron/decode-lake-stats/node_modules/@electron-forge/core/src/util/rebuild.ts:33:5

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
xkenneth@Bandley-M1 decode-lake-stats % npm test
npm ERR! Missing script: "test"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xkenneth/.npm/_logs/2021-08-07T20_48_01_486Z-debug.log
xkenneth@Bandley-M1 decode-lake-stats %
`

Reproduces how often:

Every Time

Versions

Atom : 1.58.0
Electron: 9.4.4
Chrome : 83.0.4103.122
Node : 12.14.1

macOS 11.4

Additional Information

I tried going to the suggest support forum and was met with an HTTP cert error that my browser brought up. I ignored it and still couldn't get to the forum. Any help would be much appreciated.

@yuikoito
Copy link

yuikoito commented Aug 17, 2021

@xkenneth

Hey, I think you can set asarUnpack in build option.

in your package.json
(I use electron-builder to build)

"build": {
    "asarUnpack": "node_modules/keytar"
}

electron-userland/electron-builder#3940 (comment)

My versions are as following.

Electron: 13.1.4
Node : v14.15.1
macOS 11.5.2
M1

@Wizdave97
Copy link

Wizdave97 commented Aug 19, 2021

@xkenneth @yuikoito I have a similar issue, it builds on my M1 mac but runs into an error when the app starts, it says
Screenshot from 2021-08-19 11-16-41

Any ideas?

@yuikoito
Copy link

yuikoito commented Aug 19, 2021

@Wizdave97

Did you do code-sign?
I got same error no suitable image found when I forgot to do code sign. So I am not very good at using electron but I assume your problem was happened by code sign.

I used electron-notarize and made notarize.js and wrote as follows.

require('dotenv').config()
const { notarize } = require('electron-notarize')

exports.default = async function notarizing(context) {
  const { electronPlatformName, appOutDir } = context
  if (electronPlatformName !== 'darwin') {
    return
  }

  const appName = context.packager.appInfo.productFilename

  return await notarize({
    appBundleId: process.env.APP_BUNDLE_ID,
    appPath: `${appOutDir}/${appName}.app`,
    appleId: process.env.APPLEID,
    appleIdPassword: process.env.APPLEIDPASS,
    ascProvider: process.env.ASC_PROVIDER,
  })
}

then set in package.json (I used electron-builder, and if you use another build packager, the code might be changed. But anyway you need to do code sign.)

afterSign: script/notarize.js

@yuikoito
Copy link

yuikoito commented Aug 19, 2021

@Wizdave97
also, you should add in your plist file

    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>

in package.json

  entitlements: 'entitlements.mac.plist'
  entitlementsInherit: 'entitlements.mac.plist'

When you completely do code-sign and write the above lines in plist file, your app would be work.

@maccman
Copy link

maccman commented Sep 2, 2021

@yuikoito I'm working with @Wizdave97

Yes, we have those entitlements. We are code-signing and notarizing. I'm wondering if electron-rebuild is not picking up the binary for some reason.

@yuikoito
Copy link

yuikoito commented Sep 3, 2021

@maccman Hmm.. I see. Are you sure asarUnpack option is working? I don't know about electron-forge but maybe you need to unpack for keytar.
Even so if you have still errors, I am sorry but I don't know but maybe you can try electron-builder (This works for me)

@jthoma
Copy link

jthoma commented Nov 29, 2021

Hey this seems to be that the native module has been compiled for x86_64, but actually, it should have been done for arm64e which has got me also into a fix.

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

No branches or pull requests

5 participants