·3 min read

Lighthouse on CircleCI: CHROME_PATH not set

Our Lighthouse job failed in 1 second on CircleCI because the cimg browsers image no longer ships Chrome. The fix is a short install step.

cicirclecilighthousedebugging

Contents

After we moved CI from GitHub Actions to CircleCI, the gate and build jobs passed, but Lighthouse failed in one second. This post shows the error, how we read it from the terminal, and the install step that fixed it.

The failure

The workflow had four jobs. Listing them through the API showed:

gate success
build success
lighthouse failed
preview not_run

One second is too fast for a Lighthouse run, which loads pages and measures them. It had failed before measuring anything. We read the step with the CircleCI CLI:

circleci job output list <job-id> --tail 60

The step "Lighthouse budget" had exit code 1 and this output:

lighthouse failed on / (exit 1)
Runtime error encountered: The CHROME_PATH environment variable must be set
to a Chrome/Chromium executable no older than Chrome stable.
    at new ChromePathNotSetError (.../chrome-launcher/dist/utils.js:28:9)

So chrome-launcher searched the usual places on Linux and found no browser.

Why it worked before

On GitHub's hosted runners Chrome is already installed, so our Lighthouse script never needed to know. We used the CircleCI image cimg/node:22.23.4-browsers, and we assumed the -browsers suffix meant Chrome came with it. In our run it did not. We can only say what we saw: no Chrome was found on that image. We did not check when that changed, so check the image's own docs before you rely on it either way.

The error text also holds a second condition: Chrome "no older than Chrome stable". Lighthouse refuses an old browser, so an old Chrome from a package list would not do either.

The fix

We added a step to the Lighthouse job that installs current stable Chrome, then points CHROME_PATH at it:

- run:
    name: Install Chrome
    command: |
      curl -fsSL -o /tmp/chrome.deb \
        https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
      sudo apt-get update -qq
      sudo apt-get install -y --no-install-recommends /tmp/chrome.deb
      google-chrome-stable --version
- run:
    name: Lighthouse budget
    command: |
      export CHROME_PATH="$(command -v google-chrome-stable)"
      npm run lighthouse

The --version line is there so the log shows which Chrome was installed. When a score changes later, you can see whether the browser changed too.

We checked the file with circleci config validate before pushing, then pushed. All four jobs went green on the next pipeline.

Things to know

  • The install adds time to every run, since it downloads a package each time. Caching it is possible, but we did not measure whether it pays off.
  • Performance scores differ between machines. A budget tuned on one runner type may need a second look on another, so do not compare the first CircleCI scores to old GitHub ones without thought.
  • Downloading current means the browser version moves under you. That is what Lighthouse asks for, but it is a source of change that you do not control.

The general lesson

The step failed fast and clearly, which made it easy. The habit that saved time was reading the step output instead of guessing from the job name. circleci job output list prints each step with its status, duration and exit code, so the broken step shows at once. If you move a CI job between providers, list what the old runner had preinstalled: browsers, fonts, a Docker daemon, cached tools. Each one is a silent dependency until the move.

More posts

New writing when there is something worth saying. By email or by RSS, whichever you prefer.