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
Allow the user env variable of CYPRESS_INSTALL_BINARY=''
(an empty string) to take precedence over npm config
#8488
Comments
Hi @weareoutman Can you clarify what you mean by "so we put a CYPRESS_INSTALL_BINARY=0 in PROJECT/.npmrc" - you specify the environment variables in the |
@bahmutov Yes, we disable Cypress installation of our project by default by setting
This works since at https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L467-L485 : const envVar = process.env[varName]
const configVar = process.env[`npm_config_${varName}`]
const packageConfigVar = process.env[`npm_package_config_${varName}`]
let result
if (envVar) {
debug(`Using ${varName} from environment variable`)
result = envVar
} else if (configVar) {
debug(`Using ${varName} from npm config`)
result = configVar
} else if (packageConfigVar) {
debug(`Using ${varName} from package.json config`)
result = packageConfigVar
}
So we disable Cypress installation in the |
Yeah I see what you mean. We are a little too “casty” here and this does not allow for unsetting a variable with an empty value.
…Sent from my iPhone
On Sep 18, 2020, at 22:06, Shenwei Wang ***@***.***> wrote:
@bahmutov Yes, we disable Cypress installation of our project by default by setting PROJECT/.npmrc to like this:
CYPRESS_INSTALL_BINARY=0
This works since at https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L467-L485 :
const envVar = process.env[varName]
const configVar = process.env[`npm_config_${varName}`]
const packageConfigVar = process.env[`npm_package_config_${varName}`]
let result
if (envVar) {
debug(`Using ${varName} from environment variable`)
result = envVar
} else if (configVar) {
debug(`Using ${varName} from npm config`)
result = configVar
} else if (packageConfigVar) {
debug(`Using ${varName} from package.json config`)
result = packageConfigVar
}
process.env[`npm_config_${varName}`] will be the var defined in .npmrc, which could be overridden if process.env[varName] exists.
So we disable Cypress installation in the PROJECT/.npmrc, which disable all developers from installing Cypress. And we also want the CI server to enable it by set global ENV which take precedence over project settings. But export CYPRESS_INSTALL_BINARY='' in global ENV will be ignored since it checks if (envVar), while empty string is considered as falsy.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
The code for this is done in cypress-io/cypress#8596, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
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
inPROJECT/.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 likeCYPRESS_INSTALL_BINARY=5.1.0
is not a good approach. ButCYPRESS_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 ofCYPRESS_INSTALL_BINARY=auto
or something like that.Test code to reproduce
CYPRESS_INSTALL_BINARY=0
in a project's.npmrc
(or~/.npmrc
)export CYPRESS_INSTALL_BINARY=''
in shell profile (e.g.~/.bash_profile
)npm install cypress
Possible fix
In https://github.com/cypress-io/cypress/blob/develop/cli/lib/util.js#L473
Or we can add an extra option of
allowEmptyVar
forgetEnv
to avoid potential breaking for all other env variables.Versions
Cypress: 5.1.0
Operation systems: Mac OS 10.15, CentOS 7
The text was updated successfully, but these errors were encountered: