Electron-Builder Linux updates - APPIMAGE env is not defined

Viewed 2039

I am on an Electron + Create React App stack. I am using Electron Updater (https://github.com/develar/electron-updater) for auto updates.

Platform: Linux, Format: AppImage.

When my app checks for updates, I get the following error:

APPIMAGE env is not defined.

Has someone experienced the same issue? Suggestions required.

3 Answers

Most often, this occurs when you are trying to use the auto updater in development mode (or non-packaged AppImage mode). It only works in a packed production build.


For me however, this also occurred in a packed AppImage, and turned out to be caused by using the webpack DefinePlugin, like this:

plugins: [
    new webpack.DefinePlugin({
        "process.env": {
            NODE_ENV: JSON.stringify("production")
        },
        ...

Removing the process.env definition allowed APPIMAGE to be defined once again in the distributed package. It seems the rest of the definitions can be left in place safely without breaking the auto-updater.

If removing this definition is not possible for your use-case, according to some users it's possible to simply override it at the beginning of your main thread (not renderer thread) file like this:

process.env.APPIMAGE = path.join(__dirname, 'dist', `MyApp-${app.getVersion()}.AppImage`)

... obviously with the correct file name in the 3rd argument of Path.join.

This override approach didn't seem to do anything for me though, so I myself went with simply removing process.env from the DefinePlugin definitions, but it may help in other cases.

try to use electron-builder for building your app cause this module is is in maintainance only mode. the autoUpdate for linux is not possible, you can do that only for mac and windows try to read this documentation.

Please don't use electron-updater anymore, since it is no longer supported according to its GitHub page.

Related