Problem with auto-updater


#1

I’m having a hard time figuring how to use the auto-updater module in atom-shell. From what the docs says, the following code should at least issue a request on my local server, but unfortunately it does nothing, no errors, no event dispatched, nothing.

Here’s the code I use in my window startup script (not the app main, but the window one):

remote = require 'remote'
autoUpdater = remote.require 'auto-updater'

autoUpdater.on 'error', (e,m) -> console.log('error', e, m)
autoUpdater.on 'checking-for-update', (e,m) -> console.log('checking-for-update', e, m)
autoUpdater.on 'update-available', (e,m) -> console.log('update-available', e,m)
autoUpdater.on 'update-not-available', (e,m) -> console.log('update-not-available', e,m)

try
  autoUpdater.setFeedUrl "http://localhost:3001/client/latest?version=0.1.0"
  autoUpdater.checkForUpdates()
catch e
  console.log e

I’ve tried moving this code in the app main.js with no success.

If anyone that have worked with atom-shell and have successfully implemented the auto-update feature could help me finding what I did wrong it’ll be great.

cc/ @zcbenz @kevinsawicki

Configuration

  • atom-shell v0.20.5
  • OSX 10.10.1

#2

Is your app signed?

On Mac, it has to be for auto updates to work, there is usually a message logged to the Console.app about this.


#3

Something like:

1/28/15 8:58:42.207 AM Atom[20157]: Could not get code signature for running application, application updates are disabled: Error Domain=NSOSStatusErrorDomain Code=-67062 "The operation couldn’t be completed. (OSStatus error -67062.)"

#4

I haven’t tried with a signed app yet, I’ll try this tomorrow. I thought that Squirrel was just checking the signature of downloaded release, but if it checks the requesting app it could explain why it doesn’t call the server.


#5

So it was effectively because the app wasn’t signed, thanks for the quick reply :).


#6

Hi, I have the same issue as yours. I’m using electron v0.35.1 on os x with a local server to provide updates. I indeed signed my app, but it still do nothing when code executes autoUpdater.checkForUpdates(). Any ideas?

cc @kevinsawicki


#7

Finally, I tried using https with a remote server, it works.


#8

I have been trying to get an Electron app auto-updating. Could you share how you got the app signing to work? My setFeedURL is failing because it shows the app as not signed. Thanks.


#9

For my experience, you should sign both your app currently running and the updates, and ensure your feed url is ‘https’.


#10

I’m on OSX so I can only talk for signing on mac, here’s the grunt task I use:

grunt.registerTask 'app:sign', 'Sign the application', ->
    cmd = "codesign --deep --force --verbose --sign #{certificate_name} #{app_path}"
    cmd2 = "codesign --verbose --force --sign #{certificate_name} #{app_path}/Contents/MacOS/#{app_name}"
    promise = execute(cmd).then -> execute(cmd2)

    terminate(promise).with(@async(), "Application signed #{'✓'.green}")

Which use the following helpers:

{exec, spawn} = require 'child_process'
{print} = require 'util'
Q = require 'q'

module.exports =
  terminate: (promise) ->
    with: (done, message) ->
      if typeof message is 'string'
        promise
        .then ->
          console.log message
          done?(true)
        .fail (reason) ->
          console.log reason
          done?(false)

      else if typeof message is 'function'
        promise
        .then ->
          message()
          done(true)
        .fail (reason) ->
          console.log reason
          done(false)

  execute: (command, options) ->
    console.log "execute `#{command}`".cyan
    defer = Q.defer()
    [command, args...] = if Array.isArray(command)
      command
    else
      command.split(/\s+/g)

    exe = spawn command, args, options
    exe.stdout.on 'data', (data) -> print data
    exe.stderr.on 'data', (data) -> print data
    exe.on 'exit', (status) ->
      if status is 0 then defer.resolve(status) else defer.reject(status)

    defer.promise