Search code examples
javascriptelectrongitlab-ciyarnpkg

Electron fails to install on CI


After we migrated to Electron v11 for our project from v6, we started experiencing weird CI issues, where Electron did not install properly and the pipeline failed.

Our setup:

  • Lerna
  • Monorepo
  • Yarn v1.22
  • Private npm registry

Example of such issues:

[4/4] Building fresh packages...
error /builds/xxxx/..../node_modules/electron, /builds/.../node_modules/electron, /builds/xxxx/app/node_modules/electron: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /builds/xxxx/features/yyyy/node_modules/electron
Output:
Error: dest already exists.
    at /builds/xxxx/node_modules/fs-extra/lib/move/move.js:41:31
Exit code: 1
Command: node install.js
Arguments: 
Directory: C:\gitlab\builds\pFMTxHs3\0\xxxxxx\features\yyyyy\node_modules\electron
Output:
C:\gitlab\builds\pFMTxHs3\0\xxxx\features\yyyyy\node_modules\electron\install.js:51
  throw err
  ^
[Error: ENOENT: no such file or directory, open 'C:\Users\xxxx\AppData\Local\electron\Cache\httpsgithub.comelectronelectronreleasesdownloadv7.1.4electron-v7.1.4-win32-x64.zip\electron-v7.1.4-win32-x64.zip'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\xxxx\\AppData\\Local\\electron\\Cache\\httpsgithub.comelectronelectronreleasesdownloadv7.1.4electron-v7.1.4-win32-x64.zip\\electron-v7.1.4-win32-x64.zip'

We tried deleting CI caches, Yarn caches, NPM caches all of that worked inconsistently. Sometimes we would have successful pipelines, sometimes not.


Solution

  • After a couple of months battling with this ghost, we had another error 5xx upon trying to download electron. It suddenly stopped downloading everywhere local machines and CI.

    After getting in touch with the Electron team I discovered the problem.

    We had a very old .npmrc config, which was no longer valid.

    It contained this:

    disturl=https://atom.io/download/electron
    

    When I've changed the line into this:

    disturl=https://electronjs.org/headers
    

    All of our pain was gone - our builds became stable again.

    Big thanks to the electron community!