Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(config): target nearest config dir for TOML writes#10603

Merged
jdx merged 3 commits into
mainfrom
codex/fix-set-target-config
Jun 24, 2026
Merged

fix(config): target nearest config dir for TOML writes#10603
jdx merged 3 commits into
mainfrom
codex/fix-set-target-config

Conversation

@jdx

@jdx jdx commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Tests

  • PATH="$HOME/.cargo/bin:$HOME/.local/share/mise/installs/cmake/4.3.3/cmake-4.3.3-macos-universal/CMake.app/Contents/bin:$PATH" cargo fmt --check
  • PATH="$HOME/.cargo/bin:$HOME/.local/share/mise/installs/cmake/4.3.3/cmake-4.3.3-macos-universal/CMake.app/Contents/bin:$PATH" cargo build --all-features
  • PATH="$HOME/.cargo/bin:$HOME/.local/share/mise/installs/cmake/4.3.3/cmake-4.3.3-macos-universal/CMake.app/Contents/bin:$PATH" ./e2e/run_test e2e/cli/test_set

Refs #10593


Note

Medium Risk
Changes default write targets for mise set and similar commands across nested monorepos; behavior is intentional but can surprise users who relied on the old global lowest-precedence file.

Overview
mise set (and other TOML write paths via resolve_target_config_path with prefer_toml) now pick the nearest directory that already has local TOML configs, then write to the lowest-precedence file in that directory (e.g. mise.toml over mise.local.toml). Previously, resolution could target the lowest-precedence TOML anywhere up the tree, so nested work could update a parent mise.toml instead of the project’s.

Ignored config directories (MISE_IGNORED_CONFIG_PATHS) are skipped when choosing that write target, consistent with config loading. Shared ignore logic is centralized in config_dir_is_ignored / config_path_is_ignored and reused in load_config_paths and related paths.

E2e coverage adds nested parent/myproject/inner precedence and ignored-child fallback to the parent config file.

Reviewed by Cursor Bugbot for commit 0bea14d. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • mise set now targets the nearest applicable TOML config when run from nested project directories, avoiding writes to higher-level parent configs.
    • Config write/selection now consistently honors ignored-config path rules, preventing updates to excluded TOML files and aligning warning behavior.
  • Tests
    • Expanded end-to-end scenarios for directory-hierarchy precedence and ignored-config behavior to guard against regressions.

@coderabbitai

coderabbitai Bot commented Jun 24, 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: de5b55b1-ee86-4b6e-b153-b1fec67d866f

📥 Commits

Reviewing files that changed from the base of the PR and between 98716ca and 0bea14d.

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

📝 Walkthrough

Walkthrough

mise set now resolves TOML write targets from the nearest eligible config in the current directory hierarchy, filters ignored config paths through shared helpers, and adds e2e coverage for nearest-match and ignored-directory targeting.

Changes

Nearest TOML config selection

Layer / File(s) Summary
Ignore filtering helpers
src/config/mod.rs
Shared helpers centralize ignored-directory and ignored-path checks, and config loading plus hierarchy traversal use them to filter selected paths.
Nearest TOML target resolution
src/config/mod.rs
A directory-based helper finds the nearest eligible TOML config, and resolve_target_config_path uses it for prefer_toml resolution.
Nested write targeting test
e2e/cli/test_set
The e2e suite creates nested config files, runs mise set from an inner directory, and verifies writes go to the nearest eligible config or skip an ignored directory.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hopped through nested space,
Found the closest config in place.
Ignored paths sat out the run,
While writes chose near ones, job well done. 🐇

🚥 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 summarizes the main change: TOML writes now target the nearest config directory.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit acdcf18. Configure here.

Comment thread src/config/mod.rs
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes mise set (and related TOML-write commands) to resolve the write target by finding the nearest directory that already contains a TOML config, then writing to its lowest-precedence file—rather than the old behavior of picking the lowest-precedence TOML file across the entire parent chain.

  • local_toml_config_path_from_dir replaces the old local_toml_config_paths().last() approach with a dir-by-dir walk that stops at the first non-ignored directory containing a TOML config.
  • Ignored-directory and ignored-path logic is consolidated into two helper functions (config_dir_is_ignored / config_path_is_ignored), eliminating duplicated inline predicates across load_config_paths, load_config_hierarchy_from_dir, and detect_auto_env_candidate_files.
  • E2e coverage in e2e/cli/test_set exercises the nested parent/myproject/inner hierarchy and verifies that MISE_IGNORED_CONFIG_PATHS correctly skips an inner directory and falls back to the parent config.

Confidence Score: 5/5

Safe to merge — the change is well-scoped, tested with a targeted regression, and explicit overrides (--file, --global, -E) are unaffected.

The nearest-directory walk in local_toml_config_path_from_dir correctly mirrors the existing config_file_from_dir pattern, the ignore-predicate refactor is a pure extraction with no logic change, and the two new e2e blocks directly exercise the reported hierarchy bug and the ignored-path fallback.

No files require special attention.

Important Files Changed

Filename Overview
src/config/mod.rs Core fix: introduces local_toml_config_path_from_dir for nearest-directory resolution and refactors repeated ignore-predicate logic into config_dir_is_ignored / config_path_is_ignored. Logic is consistent with existing config_file_from_dir patterns and maintains backward compatibility for explicit --file, --global, and -E targets.
e2e/cli/test_set Adds two new e2e test blocks: one for the nearest-directory write target (the core regression), one for ignored-path fallback. Both blocks include proper rm -rf parent cleanup.

Reviews (2): Last reviewed commit: "fix(config): use nearest TOML helper for..." | Re-trigger Greptile

Comment thread e2e/cli/test_set
@github-actions

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.13 x -- echo 22.7 ± 1.7 19.4 28.7 1.00
mise x -- echo 24.2 ± 2.9 20.0 62.2 1.07 ± 0.15

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.13 env 22.5 ± 1.5 19.1 27.7 1.00
mise env 24.8 ± 1.6 20.7 33.7 1.10 ± 0.10

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.13 hook-env 23.8 ± 1.8 19.7 31.9 1.00
mise hook-env 25.1 ± 2.1 21.2 33.4 1.05 ± 0.12

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.13 ls 21.1 ± 1.6 17.5 26.8 1.00
mise ls 21.6 ± 1.8 17.7 27.2 1.02 ± 0.11

xtasks/test/perf

Command mise-2026.6.13 mise Variance
install (cached) 151ms 154ms -1%
ls (cached) 68ms 68ms +0%
bin-paths (cached) 73ms 76ms -3%
task-ls (cached) 141ms 138ms +2%

@jdx jdx merged commit d5c5f35 into main Jun 24, 2026
34 checks passed
@jdx jdx deleted the codex/fix-set-target-config branch June 24, 2026 19:57
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.

1 participant