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
https://www.electron.build
MIT License
13.47k stars 1.72k forks source link

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

Open npaul007 opened 2 months ago

npaul007 commented 2 months ago

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.

slhck commented 2 months ago

"the app is not signed" -- yeah you have to sign it. This is listed at the very top of https://www.electron.build/auto-update.html

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.