fix(config): don't pick a write target that config loading ignores - #11571
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe change centralizes nearest local configuration-file resolution and updates both configuration lookup paths to use it. The end-to-end test verifies that ChangesLocal configuration resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
Greptile SummaryThe PR consolidates local configuration write-target discovery so
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
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.
7ae90ff to
c5c283f
Compare
Summary
mise usecan 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/miseonceMISE_CONFIG_DIRpoints elsewhere — is reached throughconfig_path_is_ignored, and onlylocal_toml_config_path_from_dircalls it.config_file_from_dirapplies just!is_global_config(cf).With a relocated config dir,
config_file_from_dirwalks up to$HOME, finds~/.config/mise/config.toml(a recognised local config filename), no longer recognises it as the global config, and returns it.Measured on v2026.7.15 and v2026.7.18, Linux and Windows alike.
mise setis 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 islocal_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_dirkeeps theasdf_compatone).mise setand friends: no behaviour change. Same filenames, same walk root, same fallback.mise use: gains the four filters it was missing — theMISE_NO_CONFIGshort-circuit,config_dir_is_ignored, the desymlink dedupe, andconfig_path_is_ignored.That last point is worth calling out because it is broader than the bug above:
mise usenow also honoursMISE_IGNORED_CONFIG_PATHSandMISE_NO_CONFIGwhen choosing where to write, which it arguably should have all along and whichmise setalready did. Happy to narrow this to only the#7015filter if you would rather keep the change minimal.config_file_from_dirstill walks fromenv::current_dir()rather than from itspargument. That is pre-existing and affectsuse --path/unuse --path, so I left it alone here.Tests
e2e/cli/test_config_dir_overrideis the test written for #7015 and only covered reads. It now also asserts the write target, plus a pin onmise setsince 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:
use,MISE_CONFIG_DIRrelocated, no local config~/.config/mise/config.toml./mise.tomluse, config-less deep dirplain/deep/mise.tomluse, ancestor hasmise.tomlanc/mise.tomluse,mise.toml+mise.local.tomlboth/mise.tomluse -g<config dir>/config.tomlset, nested dirsanc/mise.tomlset, lowest-precedence fileboth/mise.tomlset,MISE_IGNORED_CONFIG_PATHSanc/x/y/mise.toml🤖 Generated with Claude Code
Summary by CodeRabbit
mise useandmise setare now written to the nearest valid local configuration file.