Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electron-builder not generating app-update.yml for Linux #6322

Closed
mohsintahir opened this issue Oct 8, 2021 · 15 comments · Fixed by #6616
Closed

electron-builder not generating app-update.yml for Linux #6322

mohsintahir opened this issue Oct 8, 2021 · 15 comments · Fixed by #6616

Comments

@mohsintahir
Copy link

  • Electron-Builder Version: 22.9.1
  • Node Version: 12.12.69
  • Electron Version: 10.1.4
  • Electron Type (current, beta, nightly): current
4.2.5 Linux default target
  • Target: Linux default target

here is my package.json file

{
  "name": "",
  "version": "",
  "description": "",
  "main": "built/main.js",
  "scripts": {
    "build": "tsc && (cp -r src/assets built/assets || xcopy \"src/assets\" \"built/assets\" /y /i /s)",
    "watch": "tsc -w",
    "lint": "tslint -c tslint.json -p tsconfig.json",
    "start": "yarn run build && electron .",
    "pack": "electron-builder --dir",
    "dist": "electron-builder build",
    "postinstall": "electron-builder install-app-deps",
    "build-mac": "yarn build && electron-builder build --mac",
    "build-windows": "yarn build && electron-builder build --windows nsis --x64 --ia32 --arm64",
    "build-linux": "yarn build && electron-builder build --linux rpm deb AppImage",
    "publish-mac": "yarn build && electron-builder build --mac --publish always",
    "publish-linux": "yarn build && electron-builder build --linux rpm deb AppImage --publish always",
    "publish-windows": "yarn build && electron-builder build --windows nsis --x64 --ia32 --arm64 --publish always",
    "publish-win-mac": "yarn build && electron-builder build --mac --windows nsis --x64 --ia32 --arm64 --publish always"
  },
  "repository": "",
  "keywords": [],
  "author": {
    "name": "",
    "email": "",
    "url": ""
  },
  "license": "",
  "build": {
    "appId": "",
    "productName": "",
    "asar": true,
    "asarUnpack": [
      "**/dict/*"
    ],
    "artifactName": "app-name-${version}-${arch}.${ext}",
    "afterSign": "build/notarize.js",
    "mac": {
      "category": "public.app-category.utilities",
      "icon": "build/icon.png",
      "type": "distribution",
      "hardenedRuntime": true,
      "gatekeeperAssess": false,
      "entitlements": "build/entitlements.mac.plist",
      "entitlementsInherit": "build/entitlements.mac.plist"
    },
    "dmg": {
      "sign": false
    },
    "win": {
      "icon": "build/icon.png"
    },
    "linux": {
      "icon": "build",
      "category": "Utility"
    },
    "publish": [
      {
        "provider": "github",
        "owner": "mohsintahir",
        "repo": "some-sample-app",
        "releaseType": "draft"
      }
    ]
  },
  "devDependencies": {
    "@types/node": "12.12.69",
    "dotenv": "8.1.0",
    "electron": "10.1.4",
    "electron-builder": "22.9.1",
    "electron-notarize": "^0.1.1",
    "tslint": "5.18.0",
    "typescript": "3.9.7"
  },
  "dependencies": {
    "electron-hunspell": "1.1.2",
    "electron-json-storage": "3.1.0",
    "electron-log": "4.4.1",
    "electron-settings": "3.1.4",
    "electron-updater": "4.2.5",
    "electron-window-state": "5.0.3",
    "https-proxy-agent": "4.0.0",
    "ws": "3.3.1"
  }
}

When I build my Linux app using sudo yarn build-linux and opens the app, auto update doesn't work. When I look at the logs, it says

Error: Error: ENOENT: no such file or directory, open '/opt/{app name}/resources/app-update.yml'

It seems app-update.yml doesn't get generated. Can anybody guide me what I am doing wrong?

@mmaietta
Copy link
Collaborator

Autoupdate only supports AppImage, so your --linux rpm deb AppImage only should be generating an app-update.yml for AppImage
https://www.electron.build/auto-update

Auto-updatable Targets
macOS: DMG.
Linux: AppImage.
Windows: NSIS.

@robertpatrick
Copy link
Contributor

@mmaietta There is a problem here though. The problem is that autoUpdater.checkForUpdates() call is trying to find app-update.yml when the application is running from a non-supported installer type (e.g., rpm or deb). For example, my application uses electron-builder to create Linux AppImage, rpm and deb binaries. When I run my application from the rpm installer, I get the following log entries:

info: Checking for update
error: Error: Error: ENOENT: no such file or directory, open '/opt/WebLogic Kubernetes Toolkit UI/resources/app-update.yml'
error: Application auto-updater failed: ENOENT: no such file or directory, open '/opt/WebLogic Kubernetes Toolkit UI/resources/app-update.yml'
error: Error: ENOENT: no such file or directory, open '/opt/WebLogic Kubernetes Toolkit UI/resources/app-update.yml'

While these are not fatal, it is annoying to pollute the log file with them. Is there something I can do in the code to figure out that the application is running from a non-supported installer platform? If not, the auto-updater should probably figure this out somehow and make the calls no-ops.

@panther7
Copy link
Contributor

panther7 commented Jan 6, 2022

App-update.yml is not genereate on Windows also. I do not know, no error message.

@robertpatrick
Copy link
Contributor

robertpatrick commented Jan 6, 2022

@panther7 app-update.yaml should be generated when building the NSIS installer (and are using the electron-updater package). My project, WebLogic Kubernetes Toolkit UI, is building an NSIS installer and the build (and subsequent auto-updates checks at runtime) work fine.

Are you saying that your electron-builder build is also failing with an error about a missing app-update.yml file?

My previous comment was a runtime, rather than a build-time issue. At runtime, I added a check like this to my code to eliminate the errors from our log file.

  _supportsAutoUpdate = !(process.platform === 'linux' && !process.env.APPIMAGE);
  ...
  if (_supportsAutoUpdate) {
    const checkResult = await autoUpdater.checkForUpdates();
    ...
  } 

@panther7
Copy link
Contributor

panther7 commented Jan 6, 2022

@robertpatrick Yes, you have right, but, why does not works autoupdate with archive like zip?

@robertpatrick
Copy link
Contributor

@panther7 Because the electron-updater package does not support them. Refer to the docs to see the supported installer types.

@panther7
Copy link
Contributor

panther7 commented Jan 7, 2022

I still dont understand, why is not support create "app-update.yml" for each situation.

Now, i must "manualy" create app-update.yml with afterPack callback :-/

@rpatrick00
Copy link

@panther7 i think the better question is why electron-builder thinks you need this file for unsupported installer types

customautosys pushed a commit to customautosys/electron-builder that referenced this issue Feb 5, 2022
Suggested fix for electron-userland#6322 (not tested yet).
@mmaietta
Copy link
Collaborator

mmaietta commented Feb 5, 2022

@rpatrick00 maybe we can do something like this?

public isUpdaterActive(): boolean {
if (!this.app.isPackaged) {
this._logger.info("Skip checkForUpdatesAndNotify because application is not packed")
return false
}
return true
}

Replace with

  public isUpdaterActive(): boolean {
    if (!this.app.isPackaged) {
      this._logger.info("Skip checkForUpdates because application is not packed")
      return false
    }
    const isAppImage = process.platform === "linux" && !!process.env.APPIMAGE
    const canUpdate = this instanceof MacUpdater || this instanceof NsisUpdater || isAppImage
    if (!canUpdate) {
      this._logger.info(`Not a MacOS, NSIS, or AppImage distributable, auto-updates are not supported.`)
      return false
    }
    return true
  }

A few changes elsewhere are needed, such as checkForUpdates to enable a null Promise return, but that's minor.

My only pickle right now is: How do we detect it's an NSIS-installer app and not MSI? Do you know if there are any env vars we can check for at runtime?

@mmaietta mmaietta self-assigned this Feb 5, 2022
@mmaietta
Copy link
Collaborator

mmaietta commented Feb 5, 2022

Wait, it doesn't need that extra check. It already checks in AppImageAdapter

public isUpdaterActive(): boolean {
if (process.env["APPIMAGE"] == null) {
if (process.env["SNAP"] == null) {
this._logger.warn("APPIMAGE env is not defined, current application is not an AppImage")
} else {
this._logger.info("SNAP env is defined, updater is disabled")
}
return false
}
return super.isUpdaterActive()
}

Are you guys using checkForUpdates or checkForUpdatesAndNotify?

@robertpatrick
Copy link
Contributor

@mmaietta in our app, we are using checkForUpdates(). The app was working fine from an RPM installation but the checkForUpdates() call resulted in a few error messages being written to the log. I wrapped the call to checkForUpdates to not call it is the platform is Linux and the APPIMAGE environment variable is not set to prevent these error messages from being written to the log...

@mmaietta
Copy link
Collaborator

mmaietta commented Feb 5, 2022

The isUpdaterActive is only called in checkForUpdatesAndNotify, so I'm pulling that into checkForUpdates and that should resolve the errors in your logs I think
Opened #6616

mmaietta added a commit that referenced this issue Feb 6, 2022
…not supported (#6616)

* Moving `isUpdaterActive` check to `checkForUpdates` which is utilized by `checkForUpdatesAndNotify`. Fixes: #6322
@lacymorrow
Copy link

Huge thanks for fixing this issue! Was a big deal with appx in windows store

@sascha-schieferdecker
Copy link

After this change I cannot force the application to check for Updates if it's not packaged, even if I use checkForUpdates and place a dev-app-update.yml in the root folder of the app next to the package.json. Is this intended?

@mmaietta
Copy link
Collaborator

Yes, that seems to be intended from previous business logic

public isUpdaterActive(): boolean {
if (!this.app.isPackaged) {
this._logger.info("Skip checkForUpdatesAndNotify because application is not packed")
return false
}
return true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants