electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

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

Open pietrovismara opened this issue 1 year ago • 1 comments

  • Electron-Builder Version: 23.3.2
  • Node Version: 16.14.2
  • Electron Version: Electron 19.0.8
  • Electron Type (current, beta, nightly): current
  • Target: Windows NSIS, MacOS DMG Zip

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();
})

pietrovismara avatar Aug 14 '22 10:08 pietrovismara

Hi !

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

Thomasfds avatar Aug 20 '22 16:08 Thomasfds

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 avatar Oct 13 '22 04:10 ccorcos

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...

ccorcos avatar Oct 13 '22 04:10 ccorcos