Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide mechanism to skip binary download/install during "npm install" #1005

Closed
raygesualdo opened this issue Dec 4, 2017 · 8 comments
Closed
Labels
cli type: enhancement Requested enhancement of existing feature
Milestone

Comments

@raygesualdo
Copy link
Contributor

  • Operating System: Win10 x64
  • Cypress Version: 1.1.2
  • Browser Version: Chrome 62

Is this a Feature or Bug?

Feature

Current behavior:

When running npm install with Cypress listed as a dependency, the binary is always downloaded, unzipped and installed.

Desired behavior:

Provide a mechanism (most likely an environment variable such as CYPRESS_SKIP_BINARY_INSTALL) where the user can manually skip the binary install process.

Impetus

We have a React project with Cypress tests that are run in our CI pipeline (currently Travis). We also have our project being built and deployed by a different service (currently Netlify). Cypress is not needed during the build/deploy process but is being installed anyway. This adds additional load and time to our build process.

Test code:

In /cli/test/lib/tasks/install_spec.js:

describe('skips install', function () {
  afterEach(function () {
    delete process.env.CYPRESS_SKIP_BINARY_INSTALL
  })

  it('when environment variable is set', function () {
    process.env.CYPRESS_SKIP_BINARY_INSTALL = true

    return install.start()
    .then(() => {
      expect(download.start).not.to.be.called

      snapshot(
        'skip installation',
        normalize(this.stdout.toString())
      )
    })
  })
})

Additional Info (images, stack traces, etc)

Possible implementation at cli/lib/tasks/install.js#L176:

if (process.env.CYPRESS_SKIP_BINARY_INSTALL) {
  logger.log('Skipping binary install.')
  return Promise.resolve()
}
@jennifer-shehane jennifer-shehane added cli stage: proposal 💡 No work has been done of this issue type: enhancement Requested enhancement of existing feature labels Dec 4, 2017
@brian-mann
Copy link
Member

BTW you can do this right now with npm install --ignore-scripts

NPM has always supported this feature.

Can you just submit a PR for this? It looks like you've already written the code. Working in the CLI code is super easy.

@raygesualdo
Copy link
Contributor Author

--ignore-scripts would break other modules that are being installed.

Working on a PR now.

@brian-mann
Copy link
Member

That is true. Just throwing it out there in case none of your other deps depended on them ;-)

@raygesualdo
Copy link
Contributor Author

Submitted a PR: #1008.

@jennifer-shehane jennifer-shehane added this to the 1.1.4 milestone Dec 5, 2017
@brian-mann
Copy link
Member

Released in 1.1.4.

@raygesualdo
Copy link
Contributor Author

Thanks! Updated and tested in our CI/CD pipeline and it works like a charm.

Really excited about Cypress. Y'all have a great product. Glad to contribute to an Atlanta startup 😁

@jennifer-shehane jennifer-shehane removed the stage: proposal 💡 No work has been done of this issue label Dec 18, 2017
@NicholasBoll
Copy link
Contributor

@raygesualdo I can get the skip working just fine, but I get a complaint about "No version of Cypress is installed.". Looking into how I get that message, it looks like the path the CLI looks for is hard-coded to check node_modules/cypress/dist/. Obviously skipping the binary download didn't put it there. How did you set it up so that the binary could still be found? Do you symlink?

Actually I might have figured it out... If I call cypress from the CI command line, I'll hit the global one. If I call cypress from inside a package.json script, it will use the local one (which fails the check).

I wonder if an environment variable to the path to the binary should be supported...

@MehdiSaffar
Copy link

I can't seem to make heroku skip the install. Cypress is installed as a dev dependency. and my "heroku-prebuild" is

    "heroku-prebuild": "export CYPRESS_INSTALL_BINARY=0"

I can see Cypress unzipping and installing when I push to heroku.

@cypress-io cypress-io locked and limited conversation to collaborators Jan 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

5 participants