uv
uv copied to clipboard
Explicitly setting `index-url` to its default is not equivalent to having it undefined when syncing lockfiles with unreachable URLs
Problem description
When trying to sync from a lockfile that contains unreachable URLs, if there's any index url explicitly defined anywhere it correctly tries to get the packages from that index. Explicitly setting the default value index-url = "https://pypi.org/simple" works, too. However, if no index url is explicitly configured anywhere the sync command fails with an error reporting that the URLs in the lockfile are not reachable.
I would assume that explicitly setting the default value should be equivalent to not setting any value. If this is not the desired behavior I guess it should be mentioned in the documentation (e.g. here).
Steps to reproduce
You need to have no index URL configured anywhere (envvars, ~/.config/uv/uv.toml...)
Then, on an empty folder
uv init
uv add art
rm -r .venv
uv clean
sed -e 's/pypi.org/unresponding_url.org/' -e 's/files.pythonhosted.org/unresponding_url.org/g' -i '' uv.lock
uv sync --verbose
This command fails.
`uv sync --verbose` output
DEBUG uv 0.4.19 (Homebrew 2024-10-07)
DEBUG Found project root: `/Users/m.gabalda/Code/uv_test/test_short`
DEBUG No workspace root found, using project root
DEBUG Reading requests from `/Users/m.gabalda/Code/uv_test/test_short/.python-version`
DEBUG Searching for Python 3.12 in managed installations or system path
DEBUG Searching for managed installations at `/Users/m.gabalda/.local/share/uv/python`
DEBUG Found `cpython-3.12.5-macos-aarch64-none` at `/Users/m.gabalda/.pyenv/shims/python` (search path)
Using CPython 3.12.5 interpreter at: /Users/m.gabalda/.pyenv/versions/3.12.5/bin/python
Creating virtual environment at: .venv
DEBUG Using request timeout of 30s
DEBUG Found static `pyproject.toml` for: test-short @ file:///Users/m.gabalda/Code/uv_test/test_short
DEBUG No workspace root found, using project root
DEBUG Existing `uv.lock` satisfies workspace requirements
Resolved 2 packages in 0.61ms
DEBUG Using request timeout of 30s
DEBUG Identified uncached distribution: art==6.3
DEBUG No cache entry for: https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl
DEBUG Transient request failure for https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl, retrying: error sending request for url (https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl)
Caused by: client error (Connect)
Caused by: dns error: failed to lookup address information: nodename nor servname provided, or not known
Caused by: failed to lookup address information: nodename nor servname provided, or not known
DEBUG Transient request failure for https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl, retrying: error sending request for url (https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl)
Caused by: client error (Connect)
Caused by: dns error: failed to lookup address information: nodename nor servname provided, or not known
Caused by: failed to lookup address information: nodename nor servname provided, or not known
DEBUG Transient request failure for https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl, retrying: error sending request for url (https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl)
Caused by: client error (Connect)
Caused by: dns error: failed to lookup address information: nodename nor servname provided, or not known
Caused by: failed to lookup address information: nodename nor servname provided, or not known
DEBUG Transient request failure for https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl, retrying: error sending request for url (https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl)
Caused by: client error (Connect)
Caused by: dns error: failed to lookup address information: nodename nor servname provided, or not known
Caused by: failed to lookup address information: nodename nor servname provided, or not known
error: Failed to prepare distributions
Caused by: Failed to fetch wheel: art==6.3
Caused by: Could not connect, are you offline?
Caused by: Request failed after 3 retries
Caused by: error sending request for url (https://unresponding_url.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl)
Caused by: client error (Connect)
Caused by: dns error: failed to lookup address information: nodename nor servname provided, or not known
Caused by: failed to lookup address information: nodename nor servname provided, or not known
On the other hand, if before one defines explicitly the default value for index-url in pyproject.toml (or in ~/.config/uv/uv.toml) it succeeds in searching for the dependencies in pypi:
echo -e '\n[tool.uv]\nindex-url = "https://pypi.org/simple"' >> pyproject.toml
uv sync --verbose
`uv sync --verbose` output
DEBUG uv 0.4.19 (Homebrew 2024-10-07)
DEBUG Found project root: `/Users/m.gabalda/Code/uv_test/test_short`
DEBUG No workspace root found, using project root
DEBUG Reading requests from `/Users/m.gabalda/Code/uv_test/test_short/.python-version`
DEBUG The virtual environment's Python version satisfies `Python 3.12`
DEBUG Using request timeout of 30s
DEBUG Found static `pyproject.toml` for: test-short @ file:///Users/m.gabalda/Code/uv_test/test_short
DEBUG No workspace root found, using project root
DEBUG Ignoring existing lockfile due to missing remote index: `art` `6.3` from `https://unresponding_url.org/simple`
DEBUG Starting clean resolution
DEBUG Found static `pyproject.toml` for: test-short @ file:///Users/m.gabalda/Code/uv_test/test_short
DEBUG No workspace root found, using project root
DEBUG Solving with installed Python version: 3.12.5
DEBUG Solving with target Python version: >=3.12
DEBUG Adding direct dependency: test-short*
DEBUG Searching for a compatible version of test-short @ file:///Users/m.gabalda/Code/uv_test/test_short (*)
DEBUG Adding transitive dependency for test-short==0.1.0: art>=6.3
DEBUG No cache entry for: https://pypi.org/simple/art/
WARN Skipping file for art: art-1.0-py3.4.egg
DEBUG Searching for a compatible version of art (>=6.3)
DEBUG Selecting: art==6.3 [preference] (art-6.3-py3-none-any.whl)
DEBUG No cache entry for: https://files.pythonhosted.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl.metadata
DEBUG Tried 2 versions: art 1, test-short 1
DEBUG Split universal resolution took 19.142s
Resolved 2 packages in 19.14s
DEBUG Using request timeout of 30s
DEBUG Identified uncached distribution: art==6.3
DEBUG No cache entry for: https://files.pythonhosted.org/packages/b0/2e/2ad0cca2345e5bff23b979602917f39e844951dafe3b541935cc2850ee36/art-6.3-py3-none-any.whl
Prepared 1 package in 212ms
DEBUG Extracting file name=PackageName("art")
DEBUG Cloning /Users/m.gabalda/.cache/uv/archive-v0/NOcfpTT4LlhTH0K29ewYy/art to /Users/m.gabalda/Code/uv_test/test_short/.venv/lib/python3.12/site-packages/art
DEBUG Cloning /Users/m.gabalda/.cache/uv/archive-v0/NOcfpTT4LlhTH0K29ewYy/art-6.3.dist-info to /Users/m.gabalda/Code/uv_test/test_short/.venv/lib/python3.12/site-packages/art-6.3.dist-info
DEBUG Extracted 2 files name=PackageName("art")
DEBUG Writing entrypoints name=PackageName("art")
DEBUG No data name=PackageName("art")
DEBUG Writing extra metadata name=PackageName("art")
DEBUG Writing record name=PackageName("art")
Installed 1 package in 5ms
+ art==6.3
Versions
Platform: macOS 14.6.1 uv version: uv 0.4.19 (Homebrew 2024-10-07)