Electron-builder: electron updater, AppImage quitAndInstall exception

Created on 30 Oct 2017  Â·  28Comments  Â·  Source: electron-userland/electron-builder

I'm trying to get the AppImage auto update for linux working properly. I'm on:

"electron-builder": "^19.42.1",

"electron-updater": "^2.15.0",
"electron": "^1.7.9",

I'm building for target AppImage, and running Ubuntu 16.04.3 (64bit)

The update downloads properly:
Found version 1.2.19 (url: https://s3.amazonaws.com/noodl-update/setfeedurl-test/Noodl-1.2.19-x86_64.AppImage)
A new update is available, downloading...
Downloading update from https://s3.amazonaws.com/noodl-update/setfeedurl-test/Noodl-1.2.19-x86_64.AppImage
File has 728 changed blocks
Full: 60,575.77 KB, To download: 9,000.59 KB (15%)
New version 1.2.19 has been downloaded to /tmp/up-DmDBZB/Noodl-1.2.19-x86_64.AppImage

But after quitAndInstall() I get:

Auto install update on quit
module.js:472
throw err;
^

Error: Cannot find module '../dialog'
at Module._resolveFilename (module.js:470:15)
at Function.Module._resolveFilename (/tmp/.mount_Noodl-H3n3Ln/app/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.get [as dialog] (/tmp/.mount_Noodl-H3n3Ln/app/resources/electron.asar/browser/api/exports/electron.js:11:16)
at process. (/tmp/.mount_Noodl-H3n3Ln/app/resources/electron.asar/browser/init.js:54:31)
at emitOne (events.js:96:13)
at process.emit (events.js:191:7)
at process.emit (/tmp/.mount_Noodl-H3n3Ln/app/resources/app.asar/node_modules/source-map-support/source-map-support.js:439:21)
at process._fatalException (bootstrap_node.js:308:26)

The update file is downloaded in the same directory as the original AppImage and if I launch it manually it works fine. However the old AppImage is not deleted.

AppImage bug

Most helpful comment

Guys, I am really sorry that issue is still not addressed. In several hours you will know why, but regardless of that, I hope that till end of this week I will fix it.

All 28 comments

Same issue, AppImage updates then quit, but if i open app again is not updated and old AppImage is not deleted.

I'm getting this too, happy to help debug. Also going to prod (a little) to see if I can find the cause.

While debugging I also managed to get a segfault. segfault at 1122000019d9 ip 00007fefbafd0938 sp 00007ffc43feaa80 error 4 in libnode.so[7fefba4c9000+1385000]

I think I've figured out what's wrong here.

https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppImageUpdater.ts#L113-L117

The file at installerPath is moved to destination, and then spawn is called on installerPath. The move either needs to be a copy, or spawn needs to be called on destination.

I've been trying both options, and they solve my "Error: Cannot find module '../dialog'" problem, but I still dont get a successful update & run. So, I'm still digging into the code.

Two new observations (though I'm working from a place of limited knowledge):

  • I got errors, or silent "nothing happened" failures, until I made the copy and chmod actions synchronous. I don't know enough about what's going on to know why that might be.
  • I tested by repeatedly downloading a prerelease from github. For some reason, I would see the following output, but find the tmp directory mentioned (in this case, /tmp/up-CS67UQ) was empty. I found that I could manually copy the build to that tmp dir and keep things moving. Perhaps this is a failure in caching somewhere? EDIT: turns out this was caused by a bug in a temporary fix I had in place to circumvent #2219

After all this, I get to the point where the new version is in the original version's dir, and the original version has been deleted. However, the system is not updated, nor does the new version launch. --force-run does not help. I'm still trying to diagnose why.

EDIT2: same issue at #2200

A little more info. (Perhaps more than needed but if I dont figure out the solution, I want to have logged everything I found.)

  • If I change L113's move to a copy, and then make sure to manually copy the dist to installerPath via bash, and then spawn the dist at installerPath, I get a segfault. The new dist replaces the old one, but the appimage install doesn't occur.
  • If I keep L113 as a move, do the manual copy, and then spawn the dist at destination, it quits with no message. The new dist replaces the old one, but the appimage install doesn't occur.

Yeah I'm out of ideas. I'm stepping away. Good luck whoever comes next.

I hope all in this issue understand that this issue about non-default behaviour. Default (you don't call quitAndInstall explicitly) tested and works. As stated, explicit quitAndInstall call will be tested and fixed if need very soon (this week).

I'm finding this issue even if I don't explicitly quitAndInstall, but I am happy to wait for the update!

Hi. I'm having the same issue, but found a way (not a good one), to make it work - at least for testing purposes.

I realized that, even calling directly from node, the spawn option "env" makes the AppImage not run.

So, that's what I did:

Commented the lines:
99 to 101, 105 and 115 and finally did what @pfrazee said:

The file at installerPath is moved to destination, and then spawn is called on installerPath. The move either needs to be a copy, or spawn needs to be called on destination.

TL;DR - Changed installerPath to destination in line 121

Any news about this? I'm facing the same problem. Happy to help as well.

Also getting this issue. If I make @figueiredo-lucas and @pfrazee changes, there still appears to be a race condition where app.quit() kills the application before the move/spawn operations have completed.

Should these operations be made synchronous or should doInstall() return a promise?

I am facing the same issue. As suggested by @tullrich , the move/chmod calls should definitely be made synchronous, as it is by design not possible to wait for a promise on app.quit(). Spawn already detaches the process, so no change required there.

Changing this, fixing the destination and adding the current env by inserting ...process.env at L100 to inherit the PATH environment seems to fix it for me.

I made the changes on my fork, unfortunately I cannot PR it as the moveSync export is missing from fs-extra-p.

Seeing the same issue here ... Latest version of electron-updater (2.16.3). On AppImage, auto-update fails, trying to spawn the new app from a location where it does not exist anymore. Reading the code, I came to the same conclusion as @pfrazee : it's because of https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppImageUpdater.ts#L117-L121 . Looks like this code moves the file, then tries to spawn it from the old location.

Guys, I am really sorry that issue is still not addressed. In several hours you will know why, but regardless of that, I hope that till end of this week I will fix it.

Please try electron-updater 2.17.2 (pre-release version).

Please note — quitAndInstall is not recommended because electron-updater launches application not using gtk-launch and so, icon of the app maybe missed (the same effect as "launch by file vs launch via spotlight").

@develar I was getting this same bug on Ubuntu. Thanks so much for this update, it fixed the problem for me. Updates are working now.

Thanks!!!!!

If you use S3 / Minio — be aware of https://github.com/minio/minio/issues/5285#issuecomment-350428955 It was a part of this bug — file descriptor was not closed on such error.

@jgewehr Thanks for confirmation, electron-updater 2.17.2 marked as release.

It doesn't work for me. A new bug was occurred:
I got an exception, that the differential download fails, and it will fallback to the full download. After the full download does not happen anything: I miss the log New version has been downloaded. I do not get any notification. At the previous versions of electron-updater/electron-builder at least that worked for me.
Current versions:

  • electron-updater: 2.17.2
  • electron-builder: 19.48.3
  • electron: 1.8.1

@jayhasyee #2366 about windows :) Please try 2.17.3

I tried it (2.17.3), but I have the same issue:
The full download completes, the new AppImage is in the temp older, but does not happen anything. I do not get any notification or log about the download completing.

@develar Strange. I am logging the download-progress event. On every platform I get the logs except Ubuntu, however the file is downloading.

@jayhasyee Differential updater doesn't emit download-progress, only update-downloaded.

@develar but it fallbacks to full download. The update-downloaded is not going to be triggered too.

On windows the same issue.

[email protected] works for me. Other issues please file in a separate issue. If you use private GitHub provider — please see #2374

@develar 2.17.4 fixed on Linux, but on Windows still not.

2374 isn't this bug. I get the update-available events.

Was this page helpful?
0 / 5 - 0 ratings