feat: add tool-specific config extension and default config discovery#2636
Merged
Conversation
rattler-build now actually shares configuration with pixi and the other
rattler based tools instead of only reading a file when --config-file is
passed explicitly:
- Introduce a new `config` module with `RattlerBuildConfig`, an (empty for
now) extension struct implementing `rattler_config::config::Config`, and
the alias `Config = ConfigBase<RattlerBuildConfig>`. This is the extension
point for configuration keys that only make sense for rattler-build, while
all shared keys (default channels, mirrors, S3 options, ...) keep coming
from `rattler_config`'s `ConfigBase`. All previous uses of
`ConfigBase<()>` (opt.rs, main.rs, debug.rs and the Python bindings) now
use this alias.
- When no --config-file is given, discover and merge configuration from the
standard locations (only files that exist), later files overriding
earlier ones:
1. system-wide pixi config: /etc/pixi/config.toml
(Windows: C:\ProgramData\pixi\config.toml)
2. pixi's global config: $XDG_CONFIG_HOME/pixi/config.toml (or the
platform config dir) and $PIXI_HOME/config.toml (~/.pixi/config.toml)
3. rattler-build's own config: $XDG_CONFIG_HOME/rattler-build/config.toml
and $RATTLER_BUILD_HOME/config.toml (~/.rattler-build/config.toml)
The path logic mirrors pixi's `config_path_system`/`config_path_global`
so settings configured for pixi are picked up automatically, and can be
overridden by rattler-build specific files. Passing --config-file keeps
today's behavior of loading only the given file.
Prompt: make rattler-build share configuration with pixi and rattler, add a
tool-specific extension type for rattler-build-only keys, and load config
from the standard pixi/rattler-build locations when no --config-file is
given.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
8 tasks
The rattler crates are now published to crates.io, so switch from the pre-release versions to the released ones and adapt to the redesigned rattler_config 0.6 API. Version bumps (workspace + py-rattler-build): - rattler 0.46 -> 0.47 - rattler_cache 0.10.0 -> 0.10.2 - rattler_conda_types 0.47.2 -> 0.48 - rattler_config 0.5.2 -> 0.6 - rattler_index 0.30.5 -> 0.30.8 - rattler_menuinst 0.2.67 -> 0.2.69 - rattler_networking 0.30.0 -> 0.30.1 - rattler_package_streaming 0.26.5 -> 0.26.7 - rattler_repodata_gateway 0.29.6 -> 0.30 - rattler_shell 0.27.7 -> 0.27.9 - rattler_solve 7.1.4 -> 7.2 - rattler_upload 0.8.0 -> 0.8.3 - rattler_virtual_packages 3.0.2 -> 3.0.3 rattler_config 0.6 API adaptation (src/config.rs): - The `Config` trait now has a single required method `merge_config`; `get_extension_name` was removed and `validate`/`keys`/`is_default` gained default impls, so `RattlerBuildConfig` only implements `merge_config`. - Replace the hand-rolled ~80 lines of config-path discovery with a thin wrapper over the new shared `rattler_config::locations::config_search_paths` helper (`&["pixi", "rattler-build"]`). Discovery now also searches `/etc/rattler-build/config.toml`. Precedence, lowest first: all system-wide files, then all per-user files; within each group rattler-build overrides pixi. `load_default_config` still returns `Ok(None)` when no file exists. Unit tests and docs updated to match. Fallout from the conda_types 0.48 / repodata_gateway 0.30 bumps: - `Gateway::query` now returns `RepoDataQueryOutput` (records plus non-fatal warnings); take its `.repodata` field. - `ConfigBase` now stores the shared keys behind a `common` field (accessed via `Deref`); move `channel_config` out of `config.common`. - Migrate the deprecated `Channel::from_directory` call sites to `Channel::try_from_directory(..).expect(..)`, preserving the previous panic-on-invalid-path behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
79f6af4 to
a7c3da2
Compare
Two CI fixes after the rattler 0.47 bump: - cargo-fmt: reflow the Channel::try_from_directory call in rattler_build_core/src/types/mod.rs to rustfmt's preferred layout. - generate-cli-docs: rattler 0.47 renamed `auth status --verbose` to `--details` (conda/rattler#2551); regenerate the CLI reference to match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
Make configuration resolution traceable and pin down the loading contract:
- On startup the CLI now logs `rattler-build <version>` and the exact
config files it loaded ("Loaded configuration from: …", or "No
configuration file loaded"), at the default log level. `-v` additionally
logs the full candidate search path so users can see why a file was or
wasn't picked up.
- Document (module docs + docs/config.md) that automatic discovery happens
ONLY in the CLI. Programmatic/library consumers (pixi via
rattler_build_core, the Python bindings) never load config implicitly —
they construct and pass their own Config. `load_default_config` is the
CLI-only discovery entry point and is not called by any library path.
- Document the behavior change (discovery when no --config-file is given)
and the new search locations in docs/config.md.
No functional change to library code paths; verified rattler_build_core
does no config-from-disk loading and the Python bindings use Config::default().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
wolfv
commented
Jul 10, 2026
| .unwrap(); | ||
|
|
||
| Ok(result) | ||
| // `query` now returns a `RepoDataQueryOutput` (records plus non-fatal |
Member
Author
There was a problem hiding this comment.
Can we emit the warnings here? Or elsewhere? That would be a nice improvement.
Contributor
There was a problem hiding this comment.
Yeah it would be good to add them for sure! Now they are silently dropped.
wolfv
commented
Jul 10, 2026
wolfv
left a comment
Member
Author
There was a problem hiding this comment.
Looks good, some comments
|
|
||
| Alternatively, a single configuration file can be specified explicitly with `--config-file` (e.g. `--config-file ~/.pixi/config.toml`), which disables the automatic discovery and loads only that file. | ||
|
|
||
| !!! note "Behavior change" |
Member
Author
There was a problem hiding this comment.
Should we add a mode in which rattler-build doesn't load any configuration so users can preserve the old behavior?
baszalmstra
reviewed
Jul 10, 2026
Comment on lines
+138
to
169
| rattler_conda_types = { version = "0.48", default-features = false } | ||
| rattler_digest = { version = "1.3.1", default-features = false, features = [ | ||
| "serde", | ||
| ] } | ||
| rattler_networking = { version = "0.30.0", default-features = false } | ||
| rattler_package_streaming = { version = "0.26.5", default-features = false } | ||
| rattler_shell = { version = "0.27.7", default-features = false, features = [ | ||
| rattler_networking = { version = "0.30.1", default-features = false } | ||
| rattler_package_streaming = { version = "0.26.7", default-features = false } | ||
| rattler_shell = { version = "0.27.9", default-features = false, features = [ | ||
| "sysinfo", | ||
| ] } | ||
| rattler_git = { version = "0.1.3" } | ||
| rattler_prefix_guard = { version = "0.1.1" } | ||
|
|
||
| rattler_config = { version = "0.5.2" } | ||
| rattler = { version = "0.46.0", default-features = false, features = [ | ||
| rattler_config = { version = "0.6" } | ||
| rattler = { version = "0.47", default-features = false, features = [ | ||
| "cli-tools", | ||
| "indicatif", | ||
| ] } | ||
| rattler_cache = { version = "0.10.0", default-features = false } | ||
| rattler_index = { version = "0.30.5", default-features = false } | ||
| rattler_upload = { version = "0.8.0", default-features = false } | ||
| rattler_cache = { version = "0.10.2", default-features = false } | ||
| rattler_index = { version = "0.30.8", default-features = false } | ||
| rattler_upload = { version = "0.8.3", default-features = false } | ||
| rattler_s3 = { version = "0.2.5" } | ||
| rattler_redaction = { version = "0.2.1", default-features = false } | ||
| rattler_repodata_gateway = { version = "0.29.6", default-features = false, features = [ | ||
| rattler_repodata_gateway = { version = "0.30", default-features = false, features = [ | ||
| "gateway", | ||
| ] } | ||
| rattler_solve = { version = "7.1.4", default-features = false, features = [ | ||
| rattler_solve = { version = "7.2", default-features = false, features = [ | ||
| "resolvo", | ||
| "serde", | ||
| ] } | ||
| rattler_virtual_packages = { version = "3.0.2", default-features = false } | ||
| rattler_menuinst = "0.2.67" | ||
| rattler_virtual_packages = { version = "3.0.3", default-features = false } | ||
| rattler_menuinst = "0.2.69" | ||
|
|
Contributor
There was a problem hiding this comment.
Would be better to only bump minor patches and leave patch bumps in the lockfile only.
Addresses review feedback on #2636: - Emit non-fatal gateway warnings instead of silently dropping them. `Gateway::query` returns a `RepoDataQueryOutput` whose `warnings` were discarded at both call sites; now logged via `tracing::warn!` in render/solver.rs and publish.rs. - Add a `--no-config` flag that disables all configuration loading and discovery (built-in defaults + CLI args only), restoring the pre-discovery behavior. Mutually exclusive with `--config-file`. Documented in docs/config.md and the regenerated CLI reference. - Cargo.toml: express rattler dependency requirements at minor level (e.g. 0.30 rather than 0.30.1); the exact patch versions stay pinned in Cargo.lock only. No lockfile version changes. - Remove an unused `dirs` dependency (workspace + rattler-build crate) left over from an earlier config-discovery iteration; discovery is handled entirely by rattler_config's locations helper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
The Python bindings are a separate cargo workspace with their own Cargo.lock. Removing the unused `dirs` dependency from the rattler-build crate left that lockfile carrying a stale `dirs` edge, which the pre-commit `git diff --exit-code` check flagged. Regenerate it (drops only the edge; no version changes). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
wolfv
pushed a commit
to prefix-dev/pixi
that referenced
this pull request
Jul 10, 2026
Now that rattler-build's config PR (prefix-dev/rattler-build#2636) is merged, align pixi's rattler/rattler-build sources so the shared rattler_config / rattler_conda_types types unify: - Drop the conda/rattler [patch.crates-io] block. It pinned the pre-release rattler_config 0.5.2 / rattler 0.46 branch, which conflicts with rattler-build main (built against the released rattler_config 0.6 / rattler 0.47). rattler_config 0.6 is now released, so the patch is obsolete. - Bump rattler requirements to the released set: rattler 0.47, rattler_conda_types 0.48, rattler_config 0.6, rattler_repodata_gateway 0.30. - Patch all rattler-build crates in the tree to prefix-dev/rattler-build main (the merged config update); the crates.io rattler_build_core 0.2.8 still pins the old rattler 0.46 and is unusable until a new release is published. Lockfile re-resolved: a single copy of each shared crate from crates.io, rattler-build crates from git main, no leftover conda/rattler refs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of the effort to make rattler, rattler-build and pixi share one configuration (see conda/rattler#2557, now released as
rattler_config0.6.0). rattler-build already consumedrattler_config, but only asConfigBase<()>(no extension point) and only when--config-filewas passed explicitly — without it, no configuration was loaded at all.Two changes, plus a dependency bump:
Tool-specific extension point. New
src/config.rsdefinesRattlerBuildConfig— an (empty for now) extension struct implementing therattler_config::config::Configtrait (in 0.6 that's justmerge_config) — and the aliasConfig = ConfigBase<RattlerBuildConfig>, used everywhereConfigBase<()>was (opt.rs, main.rs, debug.rs, Python bindings). Future rattler-build-only configuration keys go into this struct; all shared keys (default channels, mirrors, S3 options, concurrency, …) keep coming fromrattler_config.Default config discovery via the shared
locationshelper. When--config-fileis not given, rattler-build now discovers and merges configuration from the standard locations (only files that exist, later overriding earlier) usingrattler_config::locations::config_search_paths(&["pixi", "rattler-build"])— the shared discovery shipped in 0.6. This replaces ~80 lines of hand-rolled path logic that previously duplicated pixi's. Precedence (lowest first): all system-wide files (/etc/pixi/config.toml,/etc/rattler-build/config.toml;C:\ProgramData\…on Windows), then all per-user files (platform config dir, then$PIXI_HOME/$RATTLER_BUILD_HOMEor~/.pixi/~/.rattler-build) — pixi first, then rattler-build, so a user's existing pixi config (mirrors, S3, channels) applies out of the box and rattler-build's own config wins.--config-filestill bypasses discovery entirely (loads only that file), and when no file exists the loader returns "no config" exactly as before.Note: this newly searches a system-wide
/etc/rattler-build/config.toml, and the ordering is now system-before-user across both tools (previously it was all-pixi-then-all-rattler-build) — a deliberate consequence of using the shared helper.Dependency bump
All rattler crates bumped to the released set that includes
rattler_config0.6: rattler 0.46→0.47, rattler_conda_types 0.47→0.48, rattler_config 0.5.2→0.6, rattler_repodata_gateway 0.29→0.30, and the rest (cache, index, menuinst, networking, package_streaming, shell, solve, upload, virtual_packages) to their current releases. Non-config fallout from the bump, all behavior-preserving:Gateway::querynow returnsRepoDataQueryOutput(repodata_gateway 0.30) —solver.rsreadsresult.repodata.ConfigBasekeys moved behind.common(Deref) — one access in the Python bindings adjusted.Channel::from_directorywas deprecated in conda_types 0.48 — 3 call sites migrated totry_from_directory(..), preserving the prior panic-on-invalid-path behavior.cargo treeconfirms a singlerattler_conda_types 0.48.0andrattler_config 0.6.0, both from crates.io.docs/config.mdand the CLI reference were updated.Testing
cargo check --workspace --all-targetsclean (zero warnings);cargo check -p py-rattler-buildclean.cargo test -p rattler-build --lib), including the discovery/ordering tests (rewritten to assert per-group precedence via the sharedlocationshelpers, using temp dirs / env overrides, not the real home dir).cargo fmt --checkandcargo clippy(-D warnings) clean on both workspaces.AI Disclosure
Tools: Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01EzYs4p6XJDj9QBcNB4ipR7