Skip to content

fix(config): don't pick a write target that config loading ignores - #11571

Merged
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix/config-write-target-ignores
Aug 2, 2026
Merged

fix(config): don't pick a write target that config loading ignores#11571
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix/config-write-target-ignores

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

mise use can pick a write target that config loading deliberately skips, so the tool it writes is never read back.

The two write-target resolvers are separate implementations of the same rule, and only one was kept current. The exclusion added for #7015 — which drops configs under the default ~/.config/mise once MISE_CONFIG_DIR points elsewhere — is reached through config_path_is_ignored, and only local_toml_config_path_from_dir calls it. config_file_from_dir applies just !is_global_config(cf).

With a relocated config dir, config_file_from_dir walks up to $HOME, finds ~/.config/mise/config.toml (a recognised local config filename), no longer recognises it as the global config, and returns it.

$ export MISE_CONFIG_DIR=/root/alt/mise

$ mise config ls
~/alt/mise/config.toml                          # the default location is excluded, as #7015 intends

$ mise use --dry-run uv@0.12.0
mise would update ~/.config/mise/config.toml    # ...but that is where the tool goes

Measured on v2026.7.15 and v2026.7.18, Linux and Windows alike. mise set is unaffected — it goes through the resolver that has the filter.

What changed

The shared walk is extracted into nearest_local_config_file(start, filenames), and both resolvers use it. That is local_toml_config_path_from_dir's existing body with the filename list and the walk root as parameters, so each caller keeps its own filenames and its own fallback (config_file_from_dir keeps the asdf_compat one).

  • mise set and friends: no behaviour change. Same filenames, same walk root, same fallback.
  • mise use: gains the four filters it was missing — the MISE_NO_CONFIG short-circuit, config_dir_is_ignored, the desymlink dedupe, and config_path_is_ignored.

That last point is worth calling out because it is broader than the bug above: mise use now also honours MISE_IGNORED_CONFIG_PATHS and MISE_NO_CONFIG when choosing where to write, which it arguably should have all along and which mise set already did. Happy to narrow this to only the #7015 filter if you would rather keep the change minimal.

config_file_from_dir still walks from env::current_dir() rather than from its p argument. That is pre-existing and affects use --path / unuse --path, so I left it alone here.

Tests

e2e/cli/test_config_dir_override is the test written for #7015 and only covered reads. It now also asserts the write target, plus a pin on mise set since it shares the resolver now.

Verified locally on Windows against the released v2026.7.18 binary; every case below matches except the first, which is the bug:

v2026.7.18 this PR
use, MISE_CONFIG_DIR relocated, no local config ~/.config/mise/config.toml ./mise.toml
use, config-less deep dir plain/deep/mise.toml same
use, ancestor has mise.toml anc/mise.toml same
use, mise.toml + mise.local.toml both/mise.toml same
use -g <config dir>/config.toml same
set, nested dirs anc/mise.toml same
set, lowest-precedence file both/mise.toml same
set, MISE_IGNORED_CONFIG_PATHS anc/x/y/mise.toml same

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Configuration changes made with mise use and mise set are now written to the nearest valid local configuration file.
    • Prevented updates from being written to excluded default configuration files.
    • Improved consistency when resolving local configuration files across directories, symlinks, and ignored paths.
  • Tests
    • Expanded end-to-end coverage to verify configuration write behavior.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: a8365bba-8ec3-4a5e-a7db-ae918d28caef

📥 Commits

Reviewing files that changed from the base of the PR and between 7ae90ff and c5c283f.

📒 Files selected for processing (2)
  • e2e/cli/test_config_dir_override
  • src/config/mod.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/config/mod.rs
  • e2e/cli/test_config_dir_override

📝 Walkthrough

Walkthrough

The change centralizes nearest local configuration-file resolution and updates both configuration lookup paths to use it. The end-to-end test verifies that mise use and mise set write to the local configuration while leaving the default configuration unchanged.

Changes

Local configuration resolution

Layer / File(s) Summary
Shared local configuration resolver
src/config/mod.rs
Added nearest_local_config_file for upward local configuration discovery. It skips ignored paths, deduplicates symlink-equivalent files, applies precedence, and excludes global files. Both configuration lookup paths use the resolver.
Write-target end-to-end validation
e2e/cli/test_config_dir_override
Added checks that mise use and mise set write to the local mise.toml and do not modify the default configuration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • jdx/mise#11103: Both changes modify configuration discovery and precedence logic in src/config/mod.rs.
  • jdx/mise#11575: Both changes modify directory-local configuration resolution in src/config/mod.rs.

Poem

A rabbit checks the config trail,
As nearest local paths prevail.
mise use writes close at hand,
mise set leaves the default unchanged.
TOML rests in its proper place.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing write targets that configuration loading ignores.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR consolidates local configuration write-target discovery so mise use and mise set avoid configuration files that loading deliberately ignores.

  • Extracts the shared nearest-local-config traversal and filtering logic.
  • Applies the existing ignore-path, ignore-directory, symlink-deduplication, and no-config handling to mise use.
  • Extends the configuration-directory override test to cover write targets for both commands.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/config/mod.rs Extracts the existing local TOML resolver and reuses it for the broader write-target resolver while retaining each caller's filename set and fallback behavior.
e2e/cli/test_config_dir_override Adds isolated end-to-end assertions that relocated configuration directories do not cause mise use or mise set to modify the ignored default config.

Reviews (2): Last reviewed commit: "fix(config): don't pick a write target t..." | Re-trigger Greptile

`mise use` and `mise set` resolve their write target through two separate
implementations of the same rule, and only one was kept current. The exclusion
added for jdx#7015 -- which drops configs under the default `~/.config/mise` once
`MISE_CONFIG_DIR` points elsewhere -- reached `local_toml_config_path_from_dir`
and not `config_file_from_dir`.

So with a relocated config dir, `mise use` walked up to `$HOME`, found
`~/.config/mise/config.toml`, no longer recognised it as the global config, and
wrote the tool into it -- a file `mise config ls` deliberately refuses to load.
The write silently had no effect.

Extract the shared walk into `nearest_local_config_file` so both resolvers get
the same filters. `mise set` is unchanged; `mise use` additionally starts
honouring `MISE_IGNORED_CONFIG_PATHS` and `MISE_NO_CONFIG`, which it should have
all along.
@JamBalaya56562
JamBalaya56562 force-pushed the fix/config-write-target-ignores branch from 7ae90ff to c5c283f Compare August 2, 2026 00:38
@jdx
jdx enabled auto-merge (squash) August 2, 2026 00:50
@jdx
jdx merged commit 56b5efb into jdx:main Aug 2, 2026
29 checks passed
@JamBalaya56562
JamBalaya56562 deleted the fix/config-write-target-ignores branch August 2, 2026 01:02
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.

2 participants