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

Make it possible to support no_proxy environment variable for download #6304

Closed
lee-thurston opened this issue Feb 3, 2020 · 8 comments · Fixed by #17702
Closed

Make it possible to support no_proxy environment variable for download #6304

lee-thurston opened this issue Feb 3, 2020 · 8 comments · Fixed by #17702
Labels
cli existing workaround type: enhancement Requested enhancement of existing feature

Comments

@lee-thurston
Copy link

Current behavior:

When downloading Cypress, the no_proxy environment variable is not taken into account.

image

Desired behavior:

When downloading, I want Cypress to be able to use the no_proxy environment so that it doesn't go through the company proxy. Using CYPRESS_INSTALL_BINARY and downloading manually isn't really a solution as we don't want CI/CD build agents to download cypress every time. Installing cypress on every build agents doesn't seem like the best solution either.

Versions

Cypress: 3.8.3

@flotwig
Copy link
Contributor

flotwig commented Feb 3, 2020

@lee-thurston There is currently no NO_PROXY support in the CLI, as you've noted.

You can try unsetting your proxy environment variables, so Cypress doesn't use them. Here are the variables that are considered:

const getProxyUrl = () => {
return process.env.HTTPS_PROXY ||
process.env.https_proxy ||
process.env.npm_config_https_proxy ||
process.env.HTTP_PROXY ||
process.env.http_proxy ||
process.env.npm_config_proxy ||
null
}

So, on macOS/Linux, this should work:

HTTPS_PROXY= HTTP_PROXY= https_proxy= http_proxy= npm_config_https_proxy= npm_config_proxy= cypress ...

@flotwig flotwig added type: enhancement Requested enhancement of existing feature cli labels Feb 3, 2020
@lee-thurston
Copy link
Author

Ahh yeah, I tried doing that but only supplied the lower case version. Using that has made it work, thanks.

@konradtoenz
Copy link

@flotwig, do we need this at all?

const getProxyUrl = () => {
return process.env.HTTPS_PROXY ||
process.env.https_proxy ||
process.env.npm_config_https_proxy ||
process.env.HTTP_PROXY ||
process.env.http_proxy ||
process.env.npm_config_proxy ||
null
}

When I set my environment variables like this:

HTTP_PROXY="http://wont.work"
NO_PROXY="download.cypress.io"

node index.js --exec install doesn't work.

After I replace the above code with

const getProxyUrl = () => {
  return undefined;
};

it works.

It looks as if the the request module figures out the proxy configuration by itself, also being aware of NO_PROXY. See the README and

https://github.com/cypress-io/request/blob/74c2136945928ef0ed7545273176fc154c34233d/lib/getProxyFromURI.js#L40-L77

@jennifer-shehane
Copy link
Member

@konradtoenz If you are behind a corporate proxy, this code reading the HTTP_PROXY variables would be required to download Cypress. Did you test behind a properly configured corporate proxy?

@konradtoenz
Copy link

@jennifer-shehane I dont't argue that the HTTP_PROXY environment variable has to be read somewhere. But to me it looks like the request module does that already:

https://github.com/cypress-io/request/blob/74c2136945928ef0ed7545273176fc154c34233d/lib/getProxyFromURI.js#L40-L77

The code in question seems to override this without reading the NO_PROXY variable.

Case in point, when I have this:

HTTP_PROXY="http://wont.work"
NO_PROXY="download.cypress.io"
const getProxyUrl = () => {
  return undefined;
};

node index.js --exec install downloads properly as the invalid proxy configuration is ignored by NO_PROXY (by the request module). When I remove the NO_PROXY variable, it doesn't download, because the request module also reads HTTP_PROXY. So I think the extra code is not needed and might even make things worse by not reading NO_PROXY.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels Aug 11, 2021
@westarne
Copy link
Contributor

westarne commented Aug 11, 2021

I've encountered the same problem when installing cypress. The problem is that we don't have a corporate proxy but need to load some dependencies via proxy from a separate registry. So our current process to install npm dependencies is

HTTP_PROXY=http://localhost:7001 HTTPS_PROXY=http://localhost:7001 NO_PROXY=localhost,.com,.io npm install

(We pretty much have everything required in the NO_PROXY except for the registry needing to be proxied)

This usually works fine, but with this issue in the download script we were not able to install the dependencies correctly as either the dependencies needing to be proxied fail or cypress.

So I've added a PR tackling the issue. Also I've added a reason to the PR why I've still overwritten the proxy which would have been added in the request module otherwise, as mentioned by @konradtoenz.

@cypress-bot cypress-bot bot added stage: waiting stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Aug 11, 2021
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Sep 14, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 20, 2021

The code for this is done in cypress-io/cypress#17702, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Sep 20, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 27, 2021

Released in 8.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v8.5.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli existing workaround type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants