Skip to content

Comments

Warn if multiple indexes include default = true#17713

Merged
konstin merged 1 commit intomainfrom
konsti/warn-double-default-index
Jan 29, 2026
Merged

Warn if multiple indexes include default = true#17713
konstin merged 1 commit intomainfrom
konsti/warn-double-default-index

Conversation

@konstin
Copy link
Member

@konstin konstin commented Jan 27, 2026

Prepare for #17011

@konstin konstin added the enhancement New feature or improvement to existing functionality label Jan 27, 2026
@konstin konstin force-pushed the konsti/warn-double-default-index branch from 2adf829 to 8dd4307 Compare January 27, 2026 09:29
----- stdout -----

----- stderr -----
warning: Found multiple indexes with `default = true`; only one index may be marked as default. This will become an error in the future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
warning: Found multiple indexes with `default = true`; only one index may be marked as default. This will become an error in the future.
warning: Found multiple indexes with `default = true`; only one index may be marked as default. This will become an error in a future release.

(just for consistency with some other warnings)

----- stdout -----

----- stderr -----
warning: Found multiple indexes with `default = true`; only one index may be marked as default. This will become an error in the future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have coverage for the case where there are multiple default indexes in a workspace defined in the root and a member? What do we expect there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently just don't load indexes from workspace members if we're in a workspace. The only time we look at the indexes is when they're referenced as a source. So basically all indexes in a member implicitly act like they have "explicit" set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is in here:

uv/crates/uv/src/lib.rs

Lines 144 to 178 in b73f6cb

// Load configuration from the filesystem, prioritizing (in order):
// 1. The configuration file specified on the command-line.
// 2. The nearest configuration file (`uv.toml` or `pyproject.toml`) above the workspace root.
// If found, this file is combined with the user configuration file.
// 3. The nearest configuration file (`uv.toml` or `pyproject.toml`) in the directory tree,
// starting from the current directory.
let workspace_cache = WorkspaceCache::default();
let filesystem = if let Some(config_file) = cli.top_level.config_file.as_ref() {
if config_file
.file_name()
.is_some_and(|file_name| file_name == "pyproject.toml")
{
warn_user!(
"The `--config-file` argument expects to receive a `uv.toml` file, not a `pyproject.toml`. If you're trying to run a command from another project, use the `--project` argument instead."
);
}
Some(FilesystemOptions::from_file(config_file)?)
} else if deprecated_isolated || cli.top_level.no_config {
None
} else if matches!(&*cli.command, Commands::Tool(_) | Commands::Self_(_)) {
// For commands that operate at the user-level, ignore local configuration.
FilesystemOptions::user()?.combine(FilesystemOptions::system()?)
} else if let Ok(workspace) =
Workspace::discover(&project_dir, &DiscoveryOptions::default(), &workspace_cache).await
{
let project = FilesystemOptions::find(workspace.install_path())?;
let system = FilesystemOptions::system()?;
let user = FilesystemOptions::user()?;
project.combine(user).combine(system)
} else {
let project = FilesystemOptions::find(&project_dir)?;
let system = FilesystemOptions::system()?;
let user = FilesystemOptions::user()?;
project.combine(user).combine(system)
};

@EliteTK
Copy link
Contributor

EliteTK commented Jan 27, 2026

Default indexes can also come from user and system configuration, do we also want to ensure only one default is specified in each of those?

Moreover, with these changes, it seems like the project/workspace default should replace the user default, and the user default should replace the system default. Right now we just put them into a vector in priority order.

@konstin
Copy link
Member Author

konstin commented Jan 27, 2026

Given that went beyond what I thought would be finishing an existing item, I see two options here:

  1. We think this change alone is valuable enough, and we want to merge it.
  2. We want a more holistic index checking that handles more cases, in which case I'd close this and Error if multiple indexes include default = true #17011 and we can open an issue to track the holistic change we want to make.

CC @charliermarsh re #17011

@zanieb
Copy link
Member

zanieb commented Jan 27, 2026

I think this case is fine without dealing with the global options for now.

@konstin
Copy link
Member Author

konstin commented Jan 29, 2026

Then I'll add this as new warning as-is.

@konstin konstin merged commit b273747 into main Jan 29, 2026
53 checks passed
@konstin konstin deleted the konsti/warn-double-default-index branch January 29, 2026 12:35
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 2, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.9.27` → `0.9.28` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.9.28`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0928)

[Compare Source](astral-sh/uv@0.9.27...0.9.28)

Released on 2026-01-29.

##### Python

- Update CPython to use [OpenSSL 3.5.5](https://github.com/openssl/openssl/releases/tag/openssl-3.5.5) which includes fixes for high severity CVEs ([python-build-standalone#960](astral-sh/python-build-standalone#960))

##### Enhancements

- Add support for Pyodide interpreter on Windows ([#&#8203;17658](astral-sh/uv#17658))
- Warn if multiple indexes include `default = true` ([#&#8203;17713](astral-sh/uv#17713))
- Skip uploads when validation reports 'Already uploaded' ([#&#8203;17412](astral-sh/uv#17412))

##### Configuration

- Add a reflink alias for the "clone" link mode ([#&#8203;17724](astral-sh/uv#17724))

##### Bug fixes

- Ensure `uv.exe` exits when `uvw.exe` or `uvx.exe` is killed ([#&#8203;17500](astral-sh/uv#17500))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45NC42IiwidXBkYXRlZEluVmVyIjoiNDIuOTQuNiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
zanieb pushed a commit that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants