Electron-builder: Auto update on macOS

Created on 1 Mar 2017  ·  19Comments  ·  Source: electron-userland/electron-builder

  • electron-builder 14.5.2

  • electron-updater 1.8.1
  • Target: mac


Similarly to issue #1310 , I'm setting up the auto-update feature on macOS as well. The publishing process is ok, but I've got an error during the update process:

  • if there is no update, everything is ok and I receive the "No update available" message correctly, but
  • if there is an update, I get this:
[Wed Mar 01 2017 09:55:58 GMT+0100 (CET)] INFO Checking for update
[Wed Mar 01 2017 09:55:58 GMT+0100 (CET)] INFO Checking for update...
[Wed Mar 01 2017 09:55:59 GMT+0100 (CET)] ERROR Error: TypeError: this.logger.warn is not a function
    at AutoUpdater.MacUpdater.nativeUpdater.on.it (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/MacUpdater.ts:16:21)
    at emitTwo (events.js:106:13)
    at AutoUpdater.emit (events.js:191:7)
    at MacUpdater.onUpdateAvailable (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/MacUpdater.ts:29:24)
    at /Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:187:10
From previous event:
    at MacUpdater.doCheckForUpdates (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:237:11)
    at /Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:142:25
    at Generator.next (<anonymous>)
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
    at MacUpdater._checkForUpdates (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:191:11)
    at MacUpdater.checkForUpdates (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:124:35)
    at Timeout._onTimeout (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/main.js:251:17)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
[Wed Mar 01 2017 09:55:59 GMT+0100 (CET)] INFO Error in auto-updater.

This is the code looking for any updates:

autoUpdater.on('checking-for-update', () => {
    log.info('Checking for update...');
})
autoUpdater.on('update-available', (ev, info) => {
    log.info('Update available.');
})
autoUpdater.on('update-not-available', (ev, info) => {
    log.info('Update not available.');
})
autoUpdater.on('error', (ev, err) => {
    log.info('Error in auto-updater.');
})
autoUpdater.on('download-progress', (ev, progressObj) => {
    log.info('Downloading update...');
})
autoUpdater.on('update-downloaded', (ev, info) => {
    log.info('Update downloaded.  Will quit and install in 5 seconds.');
    // Wait 5 seconds, then quit and install
    setTimeout(function () {
        autoUpdater.quitAndInstall();
    }, 5000)
})
// Wait a second for the window to exist before checking for updates.
setTimeout(function () {
    autoUpdater.checkForUpdates();
}, 1000);
bug electron-updater obsolete

Most helpful comment

@alexcroox
Xcode -> Preferences -> Account -> Manage certificates -> + -> macOs Development
schermata 2017-05-30 alle 10 36 29

All 19 comments

Is debug logging enabled?

Yep, this is what I see in my logs:

[Wed Mar 01 2017 09:55:58 GMT+0100 (CET)] INFO Checking for update
[Wed Mar 01 2017 09:55:58 GMT+0100 (CET)] INFO Checking for update...
[Wed Mar 01 2017 09:55:59 GMT+0100 (CET)] ERROR Error: TypeError: this.logger.warn is not a function
    at AutoUpdater.MacUpdater.nativeUpdater.on.it (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/MacUpdater.ts:16:21)
    at emitTwo (events.js:106:13)
    at AutoUpdater.emit (events.js:191:7)
    at MacUpdater.onUpdateAvailable (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/MacUpdater.ts:29:24)
    at /Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:187:10
From previous event:
    at MacUpdater.doCheckForUpdates (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:237:11)
    at /Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:142:25
    at Generator.next (<anonymous>)
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)
From previous event:
    at MacUpdater._checkForUpdates (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:191:11)
    at MacUpdater.checkForUpdates (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:124:35)
    at Timeout._onTimeout (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/main.js:251:17)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
[Wed Mar 01 2017 09:55:59 GMT+0100 (CET)] INFO Error in auto-updater.

I cannot yet check code, but you can try to: logger.warn = logger.info

That seems to have fixed it. I still have some error because the app is not correctly signed, but I'll look into it as soon as I can

I get a warning about the application not being signed (and it's not yet), then the new version on s3 is detected as an available update, but the download does not start or it gets stuck.

Here are the logs:

INFO Checking for update
INFO Checking for update...
DEBUG { Error: Could not get code signature for running application
at MacUpdater.onUpdateAvailable (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/MacUpdater.ts:29:24)
at /Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:187:10
at Generator.next ()
at Generator.tryCatcher (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/generators.js:97:49)
at Async._drainQueue (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)
preventDefault: [Function: preventDefault],
sender:
AutoUpdater {
_events: { error: [Function], 'update-downloaded': [Function] },
_eventsCount: 2 } }
ERROR Error: Error: Could not get code signature for running application
at MacUpdater.onUpdateAvailable (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/MacUpdater.ts:29:24)
at /Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/electron-updater/src/AppUpdater.ts:187:10
at Generator.next ()
at Generator.tryCatcher (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/util.js:16:23)
at PromiseSpawn._promiseFulfilled (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/generators.js:97:49)
at Async._drainQueue (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/Daniele/git/box/dist/mac/box.app/Contents/Resources/app.asar/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)
INFO Error in auto-updater.
INFO Found version 1.0.0 (url: https://mybucket.s3.amazonaws.com/setup/test/box/box-1.0.0-mac.zip)
INFO Update available.
INFO Downloading update from https://mybucket.s3.amazonaws.com/setup/test/box/box-1.0.0-mac.zip

For Mac autoupdate app is required to be signed

@develar is the signature mandatory even for testing purposes ?

Always required. You can use free Mac Developer cert. It is Squirrel.Mac requirement.

👍 ok I tried a dummy Mac Developer certificate and it worked!

Now I've got to generate a good one. I do not use Xcode, but maybe there is a way to get one without it. Thanks again

Move to close?

This is not related to this issue (sorry). @dventurino where do you get the free/dummy mac dev certificate?

This issue is not closed because TypeError: this.logger.warn is not a function is not yet investigated and fixed.

@ccnokes I had a mac development certificate generated on machine (with Xcode) at work. It's good enough for development purpouse, but not for production.

@dventurino Where in Xcode do you create this? I'd created my own in osx keychain before but not sure where to get a free "mac development" one from within Xcode?

@alexcroox
Xcode -> Preferences -> Account -> Manage certificates -> + -> macOs Development
schermata 2017-05-30 alle 10 36 29

@dventurino thanks, and I assume if I'm exporting this I can share with other team mates who can use it to sign new releases from their own machines with it? (it's an internal tool so a development cert is fine for auto updates)

Yes, I use Keychain Access to export the credential and key as a .p12 to be imported on another mac via Keychain Access.

@alexcroox yep! As @bill-pixvana said, you just have to share with them the .p12 file.

TypeError — Obsolete since electron-updater 2.0.0 (will be released today).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

antonycourtney picture antonycourtney  ·  3Comments

StickNitro picture StickNitro  ·  3Comments

noahprince22 picture noahprince22  ·  3Comments

ccorcos picture ccorcos  ·  3Comments

JohnWeisz picture JohnWeisz  ·  3Comments