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

Builder fails somewhat randomely #4098

Closed
anl176 opened this issue Jul 26, 2019 · 15 comments
Closed

Builder fails somewhat randomely #4098

anl176 opened this issue Jul 26, 2019 · 15 comments
Labels

Comments

@anl176
Copy link

anl176 commented Jul 26, 2019

  • Version: 21.1.5
  • Target: mas

Problem:
Building for mas usually fails

DevUsers-MacBook-Pro:bellcrank_desktop devuser$ yarn build
yarn run v1.17.3
$ electron-builder --mac --windows
  • electron-builder  version=21.1.5 os=18.7.0
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=darwin arch=x64 electron=5.0.8 appOutDir=dist/mac
  • packaging       platform=mas arch=x64 electron=5.0.8 appOutDir=dist/mas
  • signing         file=dist/mac/MyApp.app identityName=Developer ID Application: MREN, INC (ABC123) identityHash=MYIDENTITYHASH provisioningProfile=development.provisionprofile
  • signing         file=dist/mas/MyApp.app identityName=Developer ID Application: MREN, INC (ABC123) identityHash=MYIDENTITYHASH provisioningProfile=development.provisionprofile
  ⨯ ENOENT: no such file or directory, unlink '/var/folders/kp/kyxglrd56xv8fp1v1tyg87740000gn/T/af326d02a1f74fa001e3543e7058a0f8bd96bb49.plist'  
      stackTrace=
        Error: ENOENT: no such file or directory, unlink '/var/folders/kp/kyxglrd56xv8fp1v1tyg87740000gn/T/af326d02a1f74fa001e3543e7058a0f8bd96bb49.plist'
          at processImmediate (internal/timers.js:439:21)
        From previous event:
          at module.exports.getProvisioningProfileAsync (/Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js:66:6)
          at module.exports.preEmbedProvisioningProfile (/Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/electron-osx-sign/util-provisioning-profiles.js:153:14)
          at /Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/electron-osx-sign/sign.js:327:15
          at MacPackager.sign (/Users/devuser/Documents/bellcrank_desktop/node_modules/app-builder-lib/src/macPackager.ts:202:5)
  • building        target=DMG arch=x64 file=dist/MyApp-1.0.0.dmg
  • building        target=macOS zip arch=x64 file=dist/MyApp-1.0.0-mac.zip
  • building block map  blockMapFile=dist/MyApp-1.0.0.dmg.blockmap
  • building embedded block map  file=dist/MyApp-1.0.0-mac.zip
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Sometimes build works after I make "some" kind of modification like changing entitlements or reinstalling my dev provisioning profile. Running build after a success fails even though no files were modified.

For reference, I've been following this guide: https://samuelmeuli.com/blog/2019-04-09-publishing-an-electron-app-on-the-mac-app-store/.

I generated all macOS certs through xCode and have them in my KeyChain
Screen Shot 2019-07-26 at 12 28 10 PM
and created a dev provisioning profile to match my device.
image

I tried recreating all my certs/profiles, taking out entitlements until it was either empty or just sandbox and following the linked guide as closely as possible. Sometimes the build works but never twice in a row and usually replicating what I did to get the build working does not work.

I am completely new to Electron with very little experience in the Apple Development Ecosystem so I included as much detail as possible below. I suspect it's something like my entitlements or certs being wrong. For example, I have entitlements for push notifications but did not turn that on in my app's identifier capabilities. Then again, I got it building once by just removing entitlements <key>com.apple.application-identifier</key> up to the line <!-- Receive push notifications for macOS -->

Maybe bonus clue is when a build is successful and I try to run my app in build/dist/mas/MyApp.app it fails with the EXC_BAD_ACCESS (Code Signature Invalid) Exception. I run my code through VS Code if that matters. Many thanks and sorry for wall of text.

snippet of package.json

{
  "build": {
    "appId": "ABC123.com.MyApp.desktop",
    "mac": {
      "target": ["dmg", "mas", "zip"],
      "electronLanguages": ["en"],
      "icon": "build/logo.icns",
      "category": "public-app-category.productivity",
      "provisioningProfile": "development.provisionprofile"
    },
    "mas": {
      "type": "development"
    }
  },
  "devDependencies": {
    "electron": "^5.0.8",
    "electron-builder": "^21.1.5"
  },
  "dependencies": {
    "electron-push-receiver": "^2.1.2"
  }
}

build/entitlements.mas.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <!-- Enables App Sandbox -->
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.application-identifier</key>
    <string>ABC123.com.MyApp.desktop</string>
    <key>com.apple.developer.team-identifier</key>
    <string>ABC123</string>
    <key>com.apple.security.application-groups</key>
    <array>
        <string>ABC123.com.MyApp.desktop</string>
    </array>
    <!-- Receive push notifications for macOS -->
    <key>com.apple.developer.aps-environment</key> 
    <true/>
    <!-- Access file dialog -->
    <key>com.apple.security.files.user-selected.read-only</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <!-- Access hardware cameras -->
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.device.audio-input</key>
    <true/>
</dict>
</plist>

Relevant root file structure

package.json
development.provisioningprofile
build
    - logo.icns
    - entitlements.mas.plist
src
    - source files

What a success looks like
image

@anl176
Copy link
Author

anl176 commented Jul 29, 2019

I feel like I'm clutching at straws here but something I noticed is that all builds that starts with signing dist/mas/myApp.app instead of dist/mac/myApp.app succeed (though opening up mas/myApp.app gives EXC_BAD_ACCESS).

Screen Shot 2019-07-29 at 10 34 33 AM

The above worked after trying yarn add electron/electron-builder. I did that without removing the packages so nothing should have change.

EDIT:

Tried downgrading to 21.0.3 because of a removed comment. Gives me Unnotarized Developer Id rejection which is a much better dialogue than what I've been receiving. I thought notarizing was a step to be done later after I get the build stabilized so I've been pushing my debugging away from it. Will look into and see

@anl176
Copy link
Author

anl176 commented Jul 29, 2019

Downgraded to version 21.0.3 which prompted me to notarize the app. Followed https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/ and the build always works.

Running

  • mac/MyApp.app fails with EXC_CRASH (Code Signature Invalid)
  • mas/MyApp.app starts but it seems a library I use electron-push-receiver does not work in this instance of the app
  • locally with electron . works as I expected with electron-push-receiver working as well.

Running latest (21.1.5) causes build to fail with
image.

I do not know entirely what this means for my project but this seems like a more consistent problem to tackle. Leaving the issue open as the original question still stands as to why my builds on latest were so inconsistent (whether the app was notarized or not).

@alibosworth
Copy link

We're getting this too with the same message with v21.2.0

@anl176
Copy link
Author

anl176 commented Aug 8, 2019

@alibosworth I was not able to resolve my original issue but I followed these 2 issues to create a working PKG for putting my app on the macOS App Store.

I downgraded my Electron to 5.0.7, followed the video to get a base working project, modified it, then manually signed it with the script sign-mas.sh in the link above. Hope that helps a bit.

@alibosworth
Copy link

Thanks @anl176, we seem to be able to have everything work properly (building and signing) by downgrading to electron-builder 21.0.15 (with Electron 5.0.3).

@alibosworth
Copy link

Actually, unfortunately while downgrading to 21.0.15 lets the MAS build work, it breaks the signing of the MAC build so we are kind of stuck, because 21.2.0 works for the MAC build but not the MAS one.

@idoodler
Copy link
Contributor

I am experiencing the same issue, after trying to notarize an app which requires me to update to electron-builder 21.2.0. I basically have the same issue as @anl176 describes.

@carstengrimm
Copy link

i am having the same issues too...

@idoodler
Copy link
Contributor

Any updates on this?

@elliemaynard
Copy link

I am having the same problem on 21.2.0. I can get it to build successfully by running my build command with sudo, but this causes all sorts of issues, too many to go into in a single post.

@idoodler
Copy link
Contributor

Any update on this? Has anyone been able to successfully notarize an Electron App?

@dabeku
Copy link

dabeku commented Oct 11, 2019

+1 Same issue here

@muhsin-k
Copy link

muhsin-k commented Nov 1, 2019

I am facing the same issue. Any update on this?

@elliemaynard
Copy link

@muhzi4u There is no update, but I found a workaround. When building a MAS build, don’t pass an array into your “target”, only do “target”: “mas”. Passing additional items into the target is what’s causing the error. As long as mas is the only target it no longer fails for me.

@stale
Copy link

stale bot commented Dec 31, 2019

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Dec 31, 2019
@stale stale bot closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants