Skip to content

Add --explicit-index flag to uv add command#3

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-explicit-flag-for-dependency
Draft

Add --explicit-index flag to uv add command#3
Copilot wants to merge 4 commits intomainfrom
copilot/add-explicit-flag-for-dependency

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 31, 2025

When adding a package from a custom index, the index is globally available for all subsequent package resolutions, causing "No solution found" errors or unintended dependency confusion. Users must manually edit pyproject.toml to add explicit = true or use unsafe index strategies.

Changes

CLI: Added --explicit-index flag to uv add that marks indexes as explicit, restricting them to packages that explicitly reference them via tool.uv.sources.

TOML generation: Modified add_index() to write/remove the explicit field based on flag presence, ensuring clean updates when toggling between explicit and non-explicit indexes.

Settings propagation: Threaded explicit_index parameter through AddSettings and command invocation chain.

Usage

# Add package with explicit index
uv add paddlepaddle==3.0.0 --index https://example.org/simple --explicit-index

# Other packages now use default index, not the custom one
uv add matplotlib  # Uses PyPI, not example.org

Generates:

[[tool.uv.index]]
url = "https://example.org/simple"
explicit = true

[tool.uv.sources]
paddlepaddle = { index = "..." }

Fixes astral-sh#16291

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral-sh.github.io
    • Triggering command: /home/REDACTED/work/uv/uv/target/debug/uv add --cache-dir /tmp/uv/tests/.tmpIC8fVP/cache iniconfig==2.0.0 --index pytorch=REDACTED --explicit-index (dns block)
    • Triggering command: /home/REDACTED/work/uv/uv/target/debug/uv add --cache-dir /tmp/uv/tests/.tmpTq1kkS/cache jinja2 --index pytorch=REDACTED (dns block)
  • pypi-proxy.fly.dev
    • Triggering command: /home/REDACTED/work/uv/uv/target/debug/uv add --cache-dir /tmp/uv/tests/.tmpSjulWT/cache iniconfig==2.0.0 (dns block)
    • Triggering command: /home/REDACTED/work/uv/uv/target/debug/uv add --cache-dir /tmp/uv/tests/.tmpxXvNQQ/cache iniconfig --index ./test-index (dns block)
    • Triggering command: /home/REDACTED/work/uv/uv/target/debug/uv add --cache-dir /tmp/uv/tests/.tmpxhBu6c/cache anyio (dns block)
  • test.pypi.org
    • Triggering command: /home/REDACTED/work/uv/uv/target/debug/uv add --cache-dir /tmp/uv/tests/.tmpF3JuIW/cache iniconfig --default-index REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

I want you to work on this issue astral-sh#16291 - add the option to pass in a explicit flag when adding a dependency from a specific index


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 31, 2025 12:41
Co-authored-by: my1e5 <10064103+my1e5@users.noreply.github.com>
Co-authored-by: my1e5 <10064103+my1e5@users.noreply.github.com>
…icit-index

Co-authored-by: my1e5 <10064103+my1e5@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option to pass explicit flag when adding dependency from index Add --explicit-index flag to uv add command Oct 31, 2025
Copilot AI requested a review from my1e5 October 31, 2025 12:58
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 this pull request may close these issues.

Allow the option to make index explicit when using uv add

2 participants