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

Proxy being used even though NO_PROXY env var is set (while pip config file has proxy defined) #12610

Closed
1 task done
yaronyudov opened this issue Apr 3, 2024 · 1 comment
Labels
resolution: duplicate Duplicate of an existing issue/PR

Comments

@yaronyudov
Copy link

yaronyudov commented Apr 3, 2024

Description

I have a requirements.txt file containing both libraries from pypi.org and my personal repository.
Note that for accessing pypi.org I need to use a proxy and for my personal repository I must not use a proxy.

I understand according to the precedence-override-order env var should override configs that are defined from pip config

I used pip config set command to set:

  • install.proxy
  • install.trusted-host
  • install.extra-index-url

My pip.ini file looks like this
[install]
proxy = http://proxy host:port
trusted-host = my.repository
extra-index-url = https://my.repository/simple

My packages from pypi were installed but my personal lib from my personal repository wasn't.
I inspected the logs (ran with -vvv flag) and noticed that the connection had an error - something to do with a proxy (which I expect wouldn't be used at all).

I debugged the install command (pip 24.0 and 23.2.1) and both had the same issue.
I noticed a proxy was being used for my personal repository (even though the hostname is defined within my NO_PROXY env var).

The proxy was set within python source file pip\_vendor\requests\adapters.py
Method def get_connection(self, url, proxies=None):, code -> proxy = select_proxy(url, proxies)

Expected behavior

Expected NO_PROXY env var respected over pip config file
Meaning, proxy not used for my python repository but for others only

pip version

24.0, 23.2.1

Python version

3.9

OS

Windows

How to Reproduce

  1. Setup a python repository
  2. Install any package in that repository
  3. Setup a proxy that blocks direct calls to pypi (but has access on its own to pypi) and has no access to your repository (but you must have access to it from your machine)
  4. Create requirements.txt file that contains packages both pypi and your repository
  5. Run pip config set install.proxy = proxy
  6. Run pip config set install.trusted-host= custom.repository.hostname
  7. Run pip config set install.extra-index-url = https://custom.repository.hostname/simple
  8. Run pip install -vvv -r requirements.txt

Output

...
Could not fetch URL https://my.repository:port/simple/my-package/: connection error: HTTPSConnectionPool(host='my.repository', port=port): Max retries exceeded with url: /simple/my-package/ (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Tunnel or SSL Forbidden'))) - skipping
...

Code of Conduct

@yaronyudov yaronyudov added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Apr 3, 2024
@notatallshaw
Copy link
Member

This is a known issue, see issue #5378 and PR #12011

@uranusjr uranusjr added resolution: duplicate Duplicate of an existing issue/PR and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Apr 10, 2024
@uranusjr uranusjr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests

3 participants