Skip to content

uv fails to resolve explicit index defined in uv.toml when referenced in pyproject.toml sources #18053

@rothadamcz

Description

@rothadamcz

Summary

Issue Description

I am experiencing an issue where uv fails to recognize an index defined in uv.toml when that index is explicitly referenced by a dependency in pyproject.toml. It appears that uv attempts to validate the dependency source in pyproject.toml before fully loading or merging the index configuration from uv.toml.

Use Case & Context

We use an internal package registry that must be set as explicit due to security requirements. We maintain two separate configuration files to handle deployment constraints:

  • uv.toml: Used for local development (contains pypi index requiring internet connection).
  • uv.prod.toml: Used for production (disconnected from the internet, renamed to uv.toml by CI/CD Pipeline).

We rely on uv.toml for the index definition because pyproject.toml does not allow us to easily swap configurations based on the environment (local vs. prod) without modifying the version-controlled project file itself.

Reproduction Steps

  1. Define an internal index in uv.toml with a specific name and mark it as explicit.
  2. Add a dependency in pyproject.toml using tool.uv.sources and explicitly assign it to the index name defined in step 1.
  3. Run uv sync.

Example Configuration

uv.toml:

[[index]]
name = "gitlab"
url = "https://gitlab.example.com/api/v4/projects/1/packages/pypi/simple"
explicit = true

pyproject.toml:

[project]
name = "uv-bug-report"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
    "my-custom-package >= 0.1.0"
]

[tool.uv.sources]
my-custom-package = { index = "gitlab" }

Console output

> uv sync
  x Failed to build `uv-bug-report @ file:///C:/Users/rothadam/PycharmProjects/uv-bug-report`
  |-> Failed to parse entry: `my-custom-package`
  `-> Package `my-custom-package` references an undeclared index: `gitlab`

Platform

Windows 11 x86_64 Enterprise 25H2 (build 26200.7840)

Version

uv 0.10.3 (c75a0c6 2026-02-16)

Python version

Python 3.13.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement to existing functionalityquestionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions