Skip to content

Allow the user env variable of CYPRESS_INSTALL_BINARY='' (an empty string) to take precedence over npm config #8488

@weareoutman

Description

@weareoutman

Current behavior:

A user env variable of CYPRESS_INSTALL_BINARY='' (an empty string) cannot override the npm config.

We want to run cypress only in CI, so we put a CYPRESS_INSTALL_BINARY=0 in PROJECT/.npmrc to avoid all our developers to download the cypress binary, which is a big cost considering our poor network. And then add a user env variable in CI to let it do download. Since cypress releases frequently, a fixed version like CYPRESS_INSTALL_BINARY=5.1.0 is not a good approach. But CYPRESS_INSTALL_BINARY='' is not working too.

Desired behavior:

Allow the user env variable of CYPRESS_INSTALL_BINARY='' to take precedence over npm config. Or add a new keyword of CYPRESS_INSTALL_BINARY=auto or something like that.

Test code to reproduce

  1. Add CYPRESS_INSTALL_BINARY=0 in a project's .npmrc (or ~/.npmrc)
  2. Add export CYPRESS_INSTALL_BINARY='' in shell profile (e.g. ~/.bash_profile)
  3. Run npm install cypress

Possible fix

In https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L473

const envVar = process.env[varName]
// Instead of `if (envVar)`, prefer:
if (varName in process.env) {
  result = envVar
}

Or we can add an extra option of allowEmptyVar for getEnv to avoid potential breaking for all other env variables.

Versions

Cypress: 5.1.0
Operation systems: Mac OS 10.15, CentOS 7

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: installationIssue during installation or downloading Cypress

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions