question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Builder fails somewhat randomely

See original GitHub issue
  • 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
idoodlercommented, Sep 26, 2019

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

2reactions
alibosworthcommented, Aug 14, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

30 Construction Fails That Are Unbelievably Stupid – Part1
As you scroll through these ridiculous construction fails we can guarantee the same thoughts will cross ... Beware of the random and confusing...
Read more >
29 Hilarious Construction Fails | Comedy.com
Being an architect is no easy job, but these construction fails are ... It seems a little bit random and almost takes over...
Read more >
Funniest Construction Design Fails - YouTube
Funniest Construction Design Fails ! We're looking at some funny pictures and photos of epic design fails ! Leave a Like if you...
Read more >
6 Construction Failures, and What We Learned From Them
Things can go wrong in scientific experiments sometimes, but when it comes to engineering, getting things wrong can be disastrous.
Read more >
Lombok @Value/@Builder mapping fails when source/target ...
This issue is somewhat involved to explain, so I took the lombok example from the mapstruct-examples repo and adapted a bit to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found