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

Platform specific environment variables #5036

Closed
tomasbjerre opened this issue Aug 24, 2019 · 6 comments
Closed

Platform specific environment variables #5036

tomasbjerre opened this issue Aug 24, 2019 · 6 comments

Comments

@tomasbjerre
Copy link
Contributor

tomasbjerre commented Aug 24, 2019

We want to allow different versions of Cypress with different projects, npm packages in Git repositories.

Current behavior:

If we add this in our .npmrc

CYPRESS_INSTALL_BINARY = https://this.is/the/linux/binary.zip

We will have something that will download the wrong binary when developers use Windows.

Desired behavior:

Allow platform specific environment variables, and fall back on current behavior if no specific variables are set.

The .npmrc can have:

CYPRESS_INSTALL_BINARY___linux = https://this.is/the/linux/binary.zip
CYPRESS_INSTALL_BINARY___win32 = https://this.is/the/win32/binary.zip

Where the suffix is taken from platform names in Nodejs.

So that on Windows the effective value of CYPRESS_INSTALL_BINARY would be https://this.is/the/win32/binary.zip.

These environment variables could then be put in the .npmrc in the repository of each application.

Steps to reproduce: (app code and test code)

#5037

Versions

All of them.

@mpahuja
Copy link

mpahuja commented Aug 29, 2019

There is also https://docs.cypress.io/api/cypress-api/platform.html#Syntax along with https://docs.cypress.io/api/plugins/configuration-api.html#Usage can possibly do what you need

@tomasbjerre
Copy link
Contributor Author

Thanks. I tried cypress/plugins/index.js with:

    if (Cypress.platform === 'win32') {
        config.env.INSTALL_BINARY =
            'https://npm.asdasd.se/win32-64/cypress.zip';
    } else {
        config.env.INSTALL_BINARY =
            'https://npm.asdasd.se/linux/cypress.zip';
    }

But it did not take. Still it downloads from default location, not the ones specified above.

@mpahuja
Copy link

mpahuja commented Aug 29, 2019

should it be config.env.CYPRESS_INSTALL_BINARY instead of config.env.INSTALL_BINARY

@tomasbjerre
Copy link
Contributor Author

I tried both.

@mpahuja
Copy link

mpahuja commented Aug 29, 2019

actually by the time plugins file is read, cypress has already been installed so yeah this will not work. Sorry i misunderstood what you were trying to do here.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Sep 10, 2019
@bahmutov
Copy link
Contributor

You have to set the environment variables before starting Cypress, which you can do with a small script. See #5037 (comment) too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants