electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box

Home Page:https://www.electron.build

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autoUpdater.quitAndInstall() not working on M1 Mac, works on Intel Mac

npaul007 opened this issue · comments

  • Electron-Builder Version: 24.12.0
  • Node Version: v21.6.2
  • Electron Version: 29.0.1
  • Electron Type (current, beta, nightly): current
  • Which version of electron-updater are you using (if applicable)?: 6.1.8
  • Target: zip

What operating system are you using?

macOS

Operating System Version

MacOS Monterrey 12.0.1

What arch are you using?

arm64 (including Apple Silicon)

Expected Behavior

Desktop application closes upon confirmation of Restart, Installs software update and reboots application

Actual Behavior

Application closes and never relaunches. The dot is present below the app in the dock

Currently using a self-hosted static server to download new software versions.

src/main/index.js

// on the update being downloaded, ask user if they'd like to update
autoUpdater.on("update-downloaded", (info) => {
  const dialogOpts = {
    type: "info",
    buttons: ["Restart", "Cancel"],
    title: "Application Update",
    detail:
      "A new version has been downloaded. Restart the application to apply the updates.",
  };

  dialog
    .showMessageBox(dialogOpts)
    .then((response) => {
      if (response.response === 0) {
        setImmediate(() => {
          app.removeAllListeners("window-all-closed");

          const browserWindows = BrowserWindow.getAllWindows();
          browserWindows.forEach((browserWindow) => {
            browserWindow.close(); // Close all windows
          });

          autoUpdater.quitAndInstall();
        });
      }
    })
    .catch((err) => console.log(err));
});

electron-builder.config.js

module.exports = {
  appId: "com.organization.myapp",
  productName: "MyApp",
  asar: true,
  asarUnpack: ["resources/**"],
  directories: {
    output: "dist/${version}",
  },
  electronLanguages: "en-US",
  files: [
    "!**/.vscode/*",
    "!*.code-workspace",
    "!src/*",
    "!build/*",
    "!tests/*",
    "!public/*",
    "!osp/*",
    "!electron.vite.config.{js,ts,mjs,cjs}",
    "!electron-builder.{js,ts,mjs,cjs,json}",
    "!{.eslintignore,.eslintrc.cjs,.eslintrc.js,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}",
    "!{.env,.env.*,.npmrc,pnpm-lock.yaml}",
    "!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}",
    "!{apidoc.json,playwright.config.ts}",
  ],
  win: {
    target: [
      {
        target: "nsis",
        arch: ["x64"],
      },
    ],
    artifactName: "${productName}_Setup_(${version}).${ext}",
    extraResources: [
      {
        filter: ["resource"],
      },
    ],
    icon: "build/icons/win/icon.ico",
  },
  nsis: {
    oneClick: false,
    createDesktopShortcut: true,
    createStartMenuShortcut: true,
    allowToChangeInstallationDirectory: true,
    perMachine: true,
    deleteAppDataOnUninstall: false,
    include: "build/scripts/installer.nsh",
    runAfterFinish: true,
    license: "build/documents/LicenseFile.rtf",
  },
  mac: {
    target: "zip",
    asarUnpack: ["Resources/**"],
    icon: "build/icons/mac/icon.icns",
    artifactName: "${productName}_Setup_(${version}).${ext}",
    extraResources: [
      {
        filter: ["osp/osp.app/**"],
      },
    ],
    publish: {
      provider: "generic",
      url: "http://localhost:3030/",
    },
  },
  linux: {
    target: ["AppImage"],
    icon: "build/icons/mac/icon.icns",
    category: "AudioVideo",
    artifactName: "${productName}_Setup_(${version}).${ext}",
    extraResources: [
      // If it ever gets created, Linux OSP would go here
    ],
  },
};

I must also mention the app is not signed - I wonder if that may be contributing to the issues being faced.