question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The cypress npm package is installed, but the Cypress binary is missing.

See original GitHub issue

Current behavior

When trying to perform Cypress verify within a GitLab CI, I receive the following error:

The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress/10.3.1/Cypress/Cypress
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.
https://on.cypress.io/not-installed-ci-error

The CI code is as follows:

variables:
  npm_config_cache: '$CI_PROJECT_DIR/.npm'

E2E test:
  image: dps-nexus.service.nhsbsa:8444/<redacted>/centos-node14-cypress:1

  stage: Test
  only:
    - /^feature.*$/
    - /^bug.*$/
    - /^phase.*$/
    - /^spike.*$/
  artifacts:
    when: always
    paths:
      - cypress/
  cache: [] #This is to remove the possibility of a cache issue
  script:
    - npm ci
    - DEBUG=cypress:* $(npm bin)/cypress install cypress --force
    - DEBUG=cypress:* $(npm bin)/cypress cache path
    - DEBUG=cypress:* $(npm bin)/cypress cache list
    - DEBUG=cypress:* $(npm bin)/cypress verify
    - npm rebuild node-sass
    - ./node_modules/.bin/gulp build
    - DEBUG=cypress:* $(npm bin)/cypress run
  variables:
    CYPRESS_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/Cypress'
  allow_failure: false
  except:
    variables:
      - $CI_COMMIT_MESSAGE =~ /WIP/

Debug logs

Cypress install force:

$ DEBUG=cypress:cli $(npm bin)/cypress install cypress --force
2022-07-25T11:30:05.413Z cypress:cli NODE_OPTIONS is not set
2022-07-25T11:30:05.673Z cypress:cli parsed cli options { force: true }
2022-07-25T11:30:05.673Z cypress:cli installing with options {"force":true}
2022-07-25T11:30:05.674Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.674Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
Note: Overriding Cypress cache directory to: /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
      Previous installs of Cypress may not be found.
2022-07-25T11:30:05.675Z cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' }
2022-07-25T11:30:05.692Z cypress:cli arm uname -m result: { stdout: 'x86_64' } 
2022-07-25T11:30:05.692Z cypress:cli version in package.json is 10.3.1, version to install is 10.3.1
2022-07-25T11:30:05.693Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.693Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.693Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
2022-07-25T11:30:05.693Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.693Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.694Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
2022-07-25T11:30:05.694Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.694Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:05.694Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
2022-07-25T11:30:05.708Z cypress:cli Reading binary package.json from: /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress/10.3.1/Cypress/resources/app/package.json
2022-07-25T11:30:05.709Z cypress:cli no binary installed under cli version
2022-07-25T11:30:05.709Z cypress:cli checking local file /builds/<redacted>/10.3.1 cwd /builds/<redacted>/frontend/<redacted>-frontend
2022-07-25T11:30:05.709Z cypress:cli Cypress already installed at /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress/10.3.1
2022-07-25T11:30:05.709Z cypress:cli but the installation was forced
2022-07-25T11:30:05.709Z cypress:cli preparing to download and unzip version  10.3.1 to path /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress/10.3.1
Installing Cypress (version: 10.3.1)
[STARTED] Task without title.
2022-07-25T11:30:05.717Z cypress:cli needed Cypress version: 10.3.1
2022-07-25T11:30:05.717Z cypress:cli source url https://download.cypress.io/desktop/10.3.1?platform=linux&arch=x64
2022-07-25T11:30:05.717Z cypress:cli downloading cypress.zip to "/tmp/cypress-202.zip"
2022-07-25T11:30:05.718Z cypress:cli Downloading package {
  url: 'https://download.cypress.io/desktop/10.3.1?platform=linux&arch=x64',
  proxy: 'https://internal-outbound-nat-1350400483.eu-west-2.elb.amazonaws.com:3',
  downloadDestination: '/tmp/cypress-202.zip'
}

Cypress cache path

$ DEBUG=cypress:cli $(npm bin)/cypress cache path
2022-07-25T11:30:06.237Z cypress:cli NODE_OPTIONS is not set
2022-07-25T11:30:06.240Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:06.240Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:06.240Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
/builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress

Cypress cache list

$ DEBUG=cypress:cli $(npm bin)/cypress cache list
2022-07-25T11:30:06.754Z cypress:cli NODE_OPTIONS is not set
2022-07-25T11:30:06.756Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:06.757Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:06.757Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
┌─────────┬───────────┐
│ version │ last used │
└─────────┴───────────┘

Cypress verify

$ DEBUG=cypress:cli $(npm bin)/cypress verify
2022-07-25T11:30:07.266Z cypress:cli NODE_OPTIONS is not set
2022-07-25T11:30:07.272Z cypress:cli parsed cli options {}
2022-07-25T11:30:07.432Z cypress:cli verifying Cypress app
2022-07-25T11:30:07.432Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:07.432Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2022-07-25T11:30:07.432Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress
2022-07-25T11:30:07.433Z cypress:cli checking environment variables
2022-07-25T11:30:07.436Z cypress:cli checking if executable exists /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress/10.3.1/Cypress/Cypress
2022-07-25T11:30:07.442Z cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' }
2022-07-25T11:30:07.463Z cypress:cli arm uname -m result: { stdout: 'x86_64' } 
The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: /builds/<redacted>/frontend/<redacted>-frontend/cache/Cypress/10.3.1/Cypress/Cypress
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.
https://on.cypress.io/not-installed-ci-error
----------
Platform: linux-x64 (CentOS - 7.9.2009)
Cypress Version: 10.3.1

Cypress Version

10.3.1

Package Manager

npm

Operating system

Linux

Other

From the output, you can see the download of the binary is as expected and completes. However, this isn’t visible to Cypress when it tries to perform cypress cache list or cypress info. I have looked at https://gitlab.com/cypress-io/cypress-example-docker-gitlab but I have not found this to fix my issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Aug 10, 2022

@tbiethman - Thank you for the link to proxy-from-env, this helped me resolve the issue. I was setting the proxy through HTTP_PROXY environment variable, however, the proxy needed to be set through http_proxy (notice the lower case). I couldn’t get your script to work as that failed every time with a disconnect and it wouldn’t pick up the proxy to be http instead of https. However, I am now able to run npm ci and Cypress is downloaded and runs as expected. Thank you for your patience in troubleshooting this!

0reactions
tbiethmancommented, Aug 9, 2022

Hmm, well the test-request script I provided was using https://. I also see https:// being used for the proxy in some of the previous cypress logs you provided:

2022-07-28T09:19:03.597Z cypress:cli Downloading package {
  url: 'https://download.cypress.io/desktop/10.3.1?platform=linux&arch=x64',
  proxy: 'https://internal-outbound-nat-1350400483.eu-west-2.elb.amazonaws.com:3128',
  downloadDestination: '/tmp/cypress-196.zip'
}

I updated the test script to use http:// directly, I wonder if it still gives you the ECONNRESET error?

For reference, this logic is what is used by Cypress to determine your proxy location: https://github.com/Rob--W/proxy-from-env/blob/master/index.js#L42-L51

  var proxy =
    getEnv('npm_config_' + proto + '_proxy') ||
    getEnv(proto + '_proxy') ||
    getEnv('npm_config_proxy') ||
    getEnv('all_proxy');
  if (proxy && proxy.indexOf('://') === -1) {
    // Missing scheme in proxy, default to the requested URL's scheme.
    proxy = proto + '://' + proxy;
  }
  return proxy;

If the found proxy env value doesn’t have a protocol, it will add a protocol that matches the requested URL. So if you’re not explicitly specifying a http:// protocol (I can’t tell if you are or not), it’ll add https:// as that is the protocol of the download location (https://download.cypress.io/desktop/10.3.1?platform=linux&arch=x64).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve "The cypress npm package is installed, but the ...
The cypress npm package is installed, but the Cypress binary is missing. We expected the binary to be installed here: /root/.cache/Cypress/4.8.0 ...
Read more >
Test fails because it doesn't find the Cypress binary - GitLab
$(npm bin)/cypress run The cypress npm package is installed, but the Cypress binary is missing. We expected the binary to be installed here: ......
Read more >
Advanced Installation | Cypress Documentation
zip npm install cypress. In all cases, the fact that the binary was installed from a custom location is not saved in your...
Read more >
cypress-io/cypress - Gitter
The cypress npm package is installed, but the Cypress binary is missing. We expected the binary to be installed here: /root/.cache/Cypress/3.1.0/Cypress/Cypress ...
Read more >
@cypress/github-action - npm
name: End-to-end tests on: [push] jobs: cypress-run: runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v3 # Install NPM ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found