electron / chromedriver

Download ChromeDriver for Electron

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Offline builds requiring electron-chromedriver

ghisvail opened this issue · comments

I am trying to produce a flatpak out of an electron application which uses spectron and therefore depends on electron-chromedriver transitively. For reproducibility purposes, the build is done offline using a cache containing a pre-fetched download of all dependencies listed in package-lock.json.

However, the build fails since chromedriver cannot be downloaded in offline mode:

npm info lifecycle electron-chromedriver@1.8.0~install: electron-chromedriver@1.8.0

> electron-chromedriver@1.8.0 install /run/build/zulip/main/node_modules/electron-chromedriver
> node ./download-chromedriver.js

Downloading tmp-13-1-chromedriver-v1.8.0-linux-x64.zip
Error: getaddrinfo EAI_AGAIN github.com:443
/run/build/zulip/main/node_modules/electron-chromedriver/download-chromedriver.js:30
  if (err != null) throw err
                   ^

Error: getaddrinfo EAI_AGAIN github.com:443
    at Object._errnoException (util.js:992:11)
    at errnoException (dns.js:55:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
npm info lifecycle electron-chromedriver@1.8.0~install: Failed to exec install script

I was wondering whether there is a way to specify a local install of chromedriver to electron-chromedriver and bypass the download step, and how hard this would be to implement?

Another solution may be to patch the upstream build system in order to remove occurrences of spectron / electron-chromedriver from the npm files, but I'd rather prioritize on solutions which do not involve messing with what upstream provides.

Any ideas?

Right now, a working solution consists in patching download-chromedriver.js to inject the offline cache location to electronDownload.

It sounds to me like the sort of things that could be addressed by an environment variable. Thoughts?

@ghisvail You may use ELECTRON_CACHE env var without patching the file (as per npm/electron-download package. I got this working for my electron flatpak:

            ...
            "build-options": {
                "env": {
                    "ELECTRON_CACHE": "/run/build/rocketchat-desktop/npm-cache"
                }
            },
            "sources": [
                "generated-sources.json",
                ...
                {
                    "type": "file",
                    "url": "https://github.com/electron/electron/releases/download/v2.0.0/chromedriver-v2.0.0-linux-x64.zip",
                    "sha256": "a57f4c534bbeee806912f2b25651ef7dd3b38b5a0d7b1c6e3920f9db0dc4319b",
                    "dest-filename": "chromedriver-v2.0.0-linux-x64.zip",
                    "dest": "npm-cache"
                },
                {
                    "type": "file",
                    "url": "https://github.com/electron/electron/releases/download/v2.0.0/SHASUMS256.txt",
                    "sha256": "4d7edbfa504e1dc45ea92b02baafe7125e9f4892a98f3e6ec53fa97ec9acf8c2",
                    "dest-filename": "SHASUMS256.txt-2.0.0",
                    "dest": "npm-cache"
                }
...

Closing in light of above comment.

@ghisvail I have a similar issue like you had here. I would like to apply a patch like you did, but I have no idea of how to create a .patch file like that. Would you be so kind and point me in the right direction? I have a related issue here flatpak/flatpak-builder-tools#103

Using the ELECTRON_CACHE envvar did not work for me.

I think the move to @electron/get might have broken this? I don't see ELECTRON_CACHE being read anywhere anymore.