Skip to content

fix: allow pixi config unset to remove unknown keys#5745

Open
mvanhorn wants to merge 1 commit intoprefix-dev:mainfrom
mvanhorn:osc/5672-config-unset-unknown-keys
Open

fix: allow pixi config unset to remove unknown keys#5745
mvanhorn wants to merge 1 commit intoprefix-dev:mainfrom
mvanhorn:osc/5672-config-unset-unknown-keys

Conversation

@mvanhorn
Copy link

Summary

When pixi config unset encounters an unknown key (e.g., a deprecated config field), it now falls back to directly editing the TOML file instead of erroring. Known keys still go through the typed Config::set() path.

Why this matters

Per #5672, after repodata-config.disable-jlap was removed from the config struct, users get a warning about the unknown value but pixi config unset repodata-config.disable-jlap errors because Config::set() rejects unknown keys. Users should be able to remove any TOML key from their config file, especially deprecated ones.

Changes

  • crates/pixi_cli/src/config.rs: For AlterMode::Unset, try config.set() first (for known keys), and on failure fall back to parsing the config file as a toml_edit::DocumentMut, walking the dotted key path, and removing the leaf key directly.
  • Added remove_toml_key() helper for navigating dotted paths in TOML documents.

Testing

cargo check -p pixi_cli passes. The fallback path handles:

  • Single keys (e.g., some-key)
  • Dotted keys (e.g., repodata-config.disable-jlap)
  • Missing keys (returns error "Key not found")

Fixes #5672

This contribution was developed with AI assistance (Claude Code).

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.

pixi config unset should not error on unknown keys

1 participant