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.64k stars 1.74k forks source link

Auto-update fails with ENOENT: no such file or directory, rename #7063

Closed pietrovismara closed 9 months ago

pietrovismara commented 2 years ago

This is the same exact issue as https://github.com/electron-userland/electron-builder/issues/3622, which was ignored and then closed.

This is the error I get on macOS:

Error: Error: ENOENT: no such file or directory, rename '/Users/user/Library/Application Support/Caches/@mydesktopapp-updater/pending/temp-MyDesktopApp-0.0.46-mac.zip' -> '/Users/user/Library/Application Support/Caches/@mydesktopapp-updater/pending/MyDesktopApp-0.0.46-mac.zip'

And on Windows:

ENOENT: no such file or directory, rename 'C:\Users\39380\AppData\Local\@mydesktopapp-updater\pending\temp-MyDesktopApp Setup 0.0.46.exe' -> 'C:\Users\39380\AppData\Local\@mydesktopapp-updater\pending\MyDesktopApp Setup 0.0.46.exe'

The error is also non deterministic: retrying to update several times usually works after the 3rd tentative.

I'm using the autoUpdater as follows:

autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = false;

const updateApp = async () => {
    const quit = new Promise<void>((resolve, reject) => {
      const quitAndInstall = () => {
        try {
          autoUpdater.quitAndInstall();
          resolve();
        } catch (e: any) {
          reject(e);
        }
      };
      return setTimeout(quitAndInstall, isMac ? 10000 : 5000);
    });
    try {
      await quit;
    } catch (e: any) {
      console.log(e);
      Sentry.captureException(e);
    }
};

export const checkAppUpdates = async () => {
    return new Promise<string | null>((resolve, reject) => {
      autoUpdater.once('error', (error) => {
        reject(error);
      });

      autoUpdater.once('update-available', async () => {
        console.log('update-available');
        autoUpdater.once('update-downloaded', (info) => {
          console.log('update-downloaded');
          resolve(info.version);
        });
        autoUpdater.downloadUpdate();
      });
      autoUpdater.once('update-not-available', () => {
        console.log('update-not-available');
        resolve(null);
      });
      autoUpdater.checkForUpdates();
    });
};

checkForUpdates()
.then(updateVersion => {
  if (updateVersion) updateApp();
})
Thomasfds commented 2 years ago

Hi !

Same for me more information here : https://github.com/electron-userland/electron-builder/issues/7069#issuecomment-1221366205

ccorcos commented 2 years ago

Hmm. I'm having a similar issue...

[2022-10-12 21:08:44.307] [info]  Checking for update.
[2022-10-12 21:08:44.324] [info]  Found version 0.0.2 (url: HTML Editor-0.0.2-arm64-mac.zip, HTML Editor-0.0.2-mac.zip)
[2022-10-12 21:08:44.324] [info]  Update Available {
  version: '0.0.2',
  files: [
    {
      url: 'HTML Editor-0.0.2-arm64-mac.zip',
      sha512: 'LdoWqiyAbEY54bvEaeXOvOVDtNeD+FBpKj4o/K4mhpE/zC+Gvoi27Ok5b472/JfpP2vPtmrAi8YL43bWAdm8sg==',
      size: 80631449
    },
    {
      url: 'HTML Editor-0.0.2-mac.zip',
      sha512: 'NK4+cF5Wu3QWOCg+Y1oBGLYBt8eJHdHxJplB06EVYQMb42e1MKSa4FgvjUffq2qDq1L/g2KSmq1sW7Xz/TxBSQ==',
      size: 80137014
    }
  ],
  path: 'HTML Editor-0.0.2-arm64-mac.zip',
  sha512: 'LdoWqiyAbEY54bvEaeXOvOVDtNeD+FBpKj4o/K4mhpE/zC+Gvoi27Ok5b472/JfpP2vPtmrAi8YL43bWAdm8sg==',
  releaseDate: '2022-10-13T03:57:12.393Z'
}
[2022-10-12 21:08:44.325] [info]  Downloading update from HTML Editor-0.0.2-arm64-mac.zip, HTML Editor-0.0.2-mac.zip
[2022-10-12 21:08:44.325] [debug] Checking for macOS Rosetta environment
[2022-10-12 21:08:44.394] [info]  Checked for macOS Rosetta environment (isRosetta=false)
[2022-10-12 21:08:44.395] [debug] Checking for arm64 in uname
[2022-10-12 21:08:44.452] [info]  Checked 'uname -a': arm64=true
[2022-10-12 21:08:44.453] [info]  Downloading update from HTML Editor-0.0.2-arm64-mac.zip, HTML Editor-0.0.2-mac.zip
[2022-10-12 21:08:44.453] [debug] Checking for macOS Rosetta environment
[2022-10-12 21:08:44.512] [info]  Checked for macOS Rosetta environment (isRosetta=false)
[2022-10-12 21:08:44.512] [debug] Checking for arm64 in uname
[2022-10-12 21:08:44.570] [info]  Checked 'uname -a': arm64=true
[2022-10-12 21:08:44.571] [debug] updater cache dir: /Users/chet/Library/Application Support/Caches/html-editor-updater
[2022-10-12 21:08:44.571] [debug] updater cache dir: /Users/chet/Library/Application Support/Caches/html-editor-updater
[2022-10-12 21:08:44.882] [info]  Download Progress {
  total: 80631449,
  delta: 80631449,
  transferred: 80631449,
  percent: 100,
  bytesPerSecond: 261790419
}
[2022-10-12 21:08:44.883] [info]  Download Progress {
  total: 80631449,
  delta: 80631449,
  transferred: 80631449,
  percent: 100,
  bytesPerSecond: 261790419
}
[2022-10-12 21:08:44.883] [info]  New version 0.0.2 has been downloaded to /Users/chet/Library/Application Support/Caches/html-editor-updater/pending/HTML Editor-0.0.2-arm64-mac.zip
[2022-10-12 21:08:44.884] [debug] Creating proxy server for native Squirrel.Mac (fileToProxy=http://localhost:1234/HTML%20Editor-0.0.2-arm64-mac.zip)
[2022-10-12 21:08:44.885] [debug] Proxy server for native Squirrel.Mac is created (fileToProxy=http://localhost:1234/HTML%20Editor-0.0.2-arm64-mac.zip)
[2022-10-12 21:08:44.885] [debug] Proxy server for native Squirrel.Mac is starting to listen (fileToProxy=http://localhost:1234/HTML%20Editor-0.0.2-arm64-mac.zip)
[2022-10-12 21:08:44.887] [debug] Proxy server for native Squirrel.Mac is listening (address=http://127.0.0.1:61230, fileToProxy=http://localhost:1234/HTML%20Editor-0.0.2-arm64-mac.zip)
[2022-10-12 21:08:44.888] [info]  Update Downloaded {
  version: '0.0.2',
  files: [
    {
      url: 'HTML Editor-0.0.2-arm64-mac.zip',
      sha512: 'LdoWqiyAbEY54bvEaeXOvOVDtNeD+FBpKj4o/K4mhpE/zC+Gvoi27Ok5b472/JfpP2vPtmrAi8YL43bWAdm8sg==',
      size: 80631449
    },
    {
      url: 'HTML Editor-0.0.2-mac.zip',
      sha512: 'NK4+cF5Wu3QWOCg+Y1oBGLYBt8eJHdHxJplB06EVYQMb42e1MKSa4FgvjUffq2qDq1L/g2KSmq1sW7Xz/TxBSQ==',
      size: 80137014
    }
  ],
  path: 'HTML Editor-0.0.2-arm64-mac.zip',
  sha512: 'LdoWqiyAbEY54bvEaeXOvOVDtNeD+FBpKj4o/K4mhpE/zC+Gvoi27Ok5b472/JfpP2vPtmrAi8YL43bWAdm8sg==',
  releaseDate: '2022-10-13T03:57:12.393Z',
  downloadedFile: '/Users/chet/Library/Application Support/Caches/html-editor-updater/pending/HTML Editor-0.0.2-arm64-mac.zip'
}
[2022-10-12 21:08:44.890] [error] Error: Error: ENOENT: no such file or directory, rename '/Users/chet/Library/Application Support/Caches/html-editor-updater/pending/temp-HTML Editor-0.0.2-arm64-mac.zip' -> '/Users/chet/Library/Application Support/Caches/html-editor-updater/pending/HTML Editor-0.0.2-arm64-mac.zip'
[2022-10-12 21:08:44.894] [info]  / requested
[2022-10-12 21:08:44.896] [info]  /183cf87c455-1ea1.zip requested
[2022-10-12 21:08:44.896] [info]  /183cf87c455-1ea1.zip requested by Squirrel.Mac, pipe /Users/chet/Library/Application Support/Caches/html-editor-updater/pending/HTML Editor-0.0.2-arm64-mac.zip
[2022-10-12 21:08:44.898] [error] Error: Error: Cannot pipe "/Users/chet/Library/Application Support/Caches/html-editor-updater/pending/HTML Editor-0.0.2-arm64-mac.zip": Error: ENOENT: no such file or directory, open '/Users/chet/Library/Application Support/Caches/html-editor-updater/pending/HTML Editor-0.0.2-arm64-mac.zip'
    at ReadStream.<anonymous> (/Applications/HTML Editor.app/Contents/Resources/app.asar/main.js:134:17704)
    at ReadStream.emit (node:events:390:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
[2022-10-12 21:08:49.898] [info]  Proxy server for native Squirrel.Mac is closed (fileToProxy=http://localhost:1234/HTML%20Editor-0.0.2-arm64-mac.zip)
[2022-10-12 21:08:49.901] [warn]  Error: The network connection was lost.
[2022-10-12 21:08:49.901] [error] Error: Error: The network connection was lost.
ccorcos commented 2 years ago

I'm noticing that this logs twice even though I'm only calling it once...

autoUpdater.on("checking-for-update", () => {
    console.log("Checking for update.")
})

And then it appears to be downloading everything twice basically...

lbestftr commented 1 year ago

FYI I had a similar symptom appearing in our application, turns out we were initiating checkForUpdates twice on application load, this was causing a bunch of issues with electron-builder which disappeared once we fixed up the double call our end. Might be worth investigating if you're still stuck.

andirsun commented 1 year ago

I think this can be closed.

github-actions[bot] commented 10 months 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.

github-actions[bot] commented 9 months ago

This issue was closed because it has been stalled for 30 days with no activity.

DMiradakis commented 6 months ago

I'm noticing that this logs twice even though I'm only calling it once...

autoUpdater.on("checking-for-update", () => {
  console.log("Checking for update.")
})

And then it appears to be downloading everything twice basically...

Here in 2024 and I can 100% confirm that this was my exact problem. I manually handle downloading the new version with Electron Builder's provided methods, and my code was clashing with the autoUpdater.autodownload boolean flag being set to true. I hard-coded this property to false, and it fixed my problems.