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

pdm package manager fails to update or add packages behind a proxy #2806

Closed
1 task done
Ttayu opened this issue Apr 12, 2024 · 3 comments
Closed
1 task done

pdm package manager fails to update or add packages behind a proxy #2806

Ttayu opened this issue Apr 12, 2024 · 3 comments
Labels
🐛 bug Something isn't working

Comments

@Ttayu
Copy link

Ttayu commented Apr 12, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

PDM, version 2.13.3
Python 3.11.5

Steps to reproduce

  1. Update PDM to version 2.13.3
  2. Set up a proxy environment using environment variables http_proxy, https_proxy, HTTP_PROXY, or HTTPS_PROXY
  3. Run pdm self update or pdm add package

Actual behavior

I got the following Error (Network isunreachable)

Traceback (most recent call last):
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/pdm/core.py", line 341, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/pdm/core.py", line 259, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/pdm/core.py", line 254, in main
    self.handle(project, options)
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/pdm/core.py", line 209, in handle
    command.handle(project, options)
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/pdm/cli/commands/self_cmd.py", line 232, in handle
    version = get_latest_pdm_version_from_pypi(project, options.pre)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/pdm/cli/actions.py", line 318, in get_latest_pdm_version_from_pypi
    candidate = finder.find_best_match("pdm", allow_prereleases=prereleases).best
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/finder.py", line 391, in find_best_match
    best_match = next(iter(applicable_candidates), None)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/finder.py", line 324, in _find_packages_from_requirement
    yield from self._find_packages(requirement.name, allow_yanked)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/finder.py", line 290, in _find_packages
    return sorted(all_packages, key=self._sort_key, reverse=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/collector.py", line 178, in collect_links_from_location
    yield from _collect_links_from_index(session, location)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/collector.py", line 198, in _collect_links_from_index
    page = fetch_page(session, location)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/collector.py", line 185, in fetch_page
    resp = _get_html_response(session, location)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/unearth/collector.py", line 220, in _get_html_response
    resp = session.get(
           ^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_client.py", line 1054, in get
    return self.request(
           ^^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_client.py", line 827, in request
    return self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/Ttayu/.asdf/installs/pdm/2.10.3/venv/lib/python3.11/site-packages/hishel/_sync/_transports.py", line 215, in handle_request
    response = self._transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_transports/default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "/home/Ttayu/.asdf/installs/python/3.11.5/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/data/private/Ttayu/sample_project/__pypackages__/3.11/lib/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 101] Network is unreachable

Expected behavior

When a proxy is set up using environment variables, PDM should be able to recognize and use the proxy settings to execute the pdm self update and pdm add package commands successfully. The commands should work as intended, allowing users to update PDM itself or add new packages to their projects.

httpx.Client in src/pdm/models/session.py on line 148

-        httpx.Client.__init__(self, mounts=mounts, follow_redirects=True, transport=transport, **kwargs)
+       proxies = ...  # get proxy from environment variable or pdm.toml?
+       httpx.Client.__init__(self, mounts=mounts, follow_redirects=True, transport=transport, proxies=proxies, **kwargs)

Additional Notes

@Ttayu Ttayu added the 🐛 bug Something isn't working label Apr 12, 2024
@huxuan
Copy link
Contributor

huxuan commented Apr 12, 2024

This should have been fixed by #2798
Please also refer to #2788

@Ttayu
Copy link
Author

Ttayu commented Apr 12, 2024

Oh, sorry I didn't check the solved issue/PR..
Thank you.

@Ttayu Ttayu closed this as completed Apr 12, 2024
@frostming
Copy link
Collaborator

No worry, will do a release shortly to solve all regressions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants