feat(config): automatically define platform environments (auto_env)#10316
Conversation
Adds a new tri-state auto_env early-init setting (MISE_AUTO_ENV /
.miserc.toml) that activates platform-derived config environments —
unix (os family), {os}, and {os}-{arch} (e.g. windows-x64,
macos-arm64) — for config file discovery and lockfile selection.
Explicit MISE_ENV entries keep higher precedence, and the platform
envs are deliberately not added to MISE_ENV itself, so {{ mise_env }}
templates and MISE_ENV propagation to subprocesses are unaffected.
Phased rollout:
- now: off by default; opt in with auto_env=true
- 2026.12.0: warn when a platform config file exists that would be
newly loaded (silence with auto_env=false, adopt with auto_env=true)
- 2027.6.0: on by default; auto_env=false opts out
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI 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)
📝 WalkthroughWalkthroughThis PR implements platform-based automatic environment detection ( ChangesAuto-env platform environment discovery and selection
🎯 3 (Moderate) | ⏱️ ~25 minutes sequenceDiagram
participant Client as CLI
participant Env as src::env
participant Config as src::config::Config::load
participant FS as Filesystem
participant Lockfile as src::lockfile::read_all_lockfiles
Client->>Env: compute MISE_ENV_WITH_AUTO (AUTO_ENV_NAMES + MISE_ENV)
Client->>Config: load using DEFAULT_CONFIG_FILENAMES (with auto envs)
Config->>FS: discover files via env_config_patterns
FS->>Config: return candidate files
Config->>Config: should_warn_auto_env -> warn_if_auto_env_files_exist
Client->>Lockfile: read_all_lockfiles (uses AUTO_ENV_NAMES + MISE_ENV)
Lockfile->>FS: probe mise.<env>.lock / .local.lock in precedence
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/config/mod.rs`:
- Around line 1254-1283: The function detect_auto_env_candidate_files may return
duplicate PathBufs (e.g., same user config found via all_dirs() and
dirs::CONFIG); update detect_auto_env_candidate_files to deduplicate before
returning/using the list by collecting found into a HashSet<PathBuf> (or call
sort_unstable() then dedup()) and then produce a Vec<PathBuf> from that set;
modify the code around variable found (and any subsequent warning output) to use
the deduplicated collection so the one-time warning no longer shows repeated
paths.
In `@src/lockfile.rs`:
- Around line 1647-1649: The loop over
env::MISE_ENV.iter().chain(env::AUTO_ENV_NAMES.iter().rev()) can yield the same
env_name twice and cause duplicate Lockfile::read(&p) disk reads; fix by
deduplicating the combined iterator before constructing paths: create a mutable
HashSet (or similar) named e.g. seen and iterate the chained iterator, skipping
any env_name already in seen (insert when first seen) so
root.join(format!("mise.{env_name}.local.lock")) and the Lockfile::read(&p) call
only run once per unique env name; apply the same dedupe approach to the other
loop that also constructs lockfile paths.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8f94068a-4395-4ff0-b725-eca06b8e2285
📒 Files selected for processing (11)
docs/configuration.mddocs/configuration/environments.mde2e/config/test_config_auto_enve2e/lockfile/test_lockfile_auto_envschema/mise.jsonschema/miserc.jsonsettings.tomlsrc/config/miserc.rssrc/config/mod.rssrc/env.rssrc/lockfile.rs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7eb4f2a. Configure here.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Greptile SummaryAdds a tri-state
Confidence Score: 5/5Safe to merge. The feature is off by default, has explicit opt-in/opt-out, and the rollout path is fully gated by version comparisons. The lazy-static initialization chain is correct (miserc is always read before DEFAULT_CONFIG_FILENAMES is evaluated), the dedupe logic between auto and explicit MISE_ENV entries is consistent across config loading and lockfile reading, and the warning window path is guarded to not affect shims or hook-env. No logic errors were found across the changed files. No files require special attention. Important Files Changed
Reviews (4): Last reviewed commit: "fix(config): simplify boolean expression..." | Re-trigger Greptile |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.6.2 x -- echo |
23.2 ± 1.9 | 18.5 | 30.2 | 1.00 |
mise x -- echo |
25.1 ± 2.9 | 19.9 | 66.3 | 1.08 ± 0.15 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.6.2 env |
23.2 ± 1.7 | 19.9 | 30.8 | 1.00 |
mise env |
23.9 ± 1.8 | 19.3 | 29.6 | 1.03 ± 0.11 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.6.2 hook-env |
23.2 ± 1.6 | 19.7 | 29.3 | 1.00 |
mise hook-env |
24.7 ± 1.9 | 20.4 | 31.6 | 1.06 ± 0.11 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.6.2 ls |
18.5 ± 1.4 | 15.8 | 24.5 | 1.00 |
mise ls |
21.6 ± 2.3 | 16.0 | 31.9 | 1.17 ± 0.15 |
ls measured 17% slower, but the relative uncertainty overlaps the 10% threshold. |
xtasks/test/perf
| Command | mise-2026.6.2 | mise | Variance |
|---|---|---|---|
| install (cached) | 155ms | 160ms | -3% |
| ls (cached) | 73ms | 73ms | +0% |
| bin-paths (cached) | 86ms | 85ms | +1% |
| task-ls (cached) | 165ms | 165ms | +0% |

What
Adds a new tri-state
auto_envearly-init setting (MISE_AUTO_ENVenv var orauto_envin.miserc.toml). When enabled, mise automatically treats platform-derived names as active config environments:unix(os family, unix platforms only){os}—linux/macos/windows{os}-{arch}— e.g.windows-x64,macos-arm64(using mise's remapped arch names)so config files like
mise.windows.toml,mise/config.macos-arm64.toml, ormise.unix.toml(and their.local.tomlvariants, plus global/systemconfig.{env}.toml) load automatically, and matchingmise.<env>.locklockfiles are selected.Precedence is
unix<{os}<{os}-{arch}< explicitMISE_ENVentries, with dedupe when a user explicitly lists a platform name. The platform envs are deliberately not added toMISE_ENVitself: the{{ mise_env }}template variable andMISE_ENVpropagation to subprocesses/tasks only reflect explicit environments.Phased rollout
auto_env = true.auto_enveither way). The check is skipped for shims andhook-envso the per-prompt path pays nothing.auto_env = falsestill opts out. Adebug_assert(same pattern asdeprecated_at!) reminds us to delete the transitional warning code then.Reviewer notes
rc = true) because settings loading itself depends on config discovery (Settings::try_get()→ALL_TOML_CONFIG_FILES→DEFAULT_CONFIG_FILENAMES→MISE_ENV) — same constraint and docs caveat as the existingenv/ceiling_pathsrc settings.src/env.rs(AUTO_ENV_NAMES/MISE_ENV_WITH_AUTO); consumers areDEFAULT_CONFIG_FILENAMES, the global/systemCONFIG_FILENAMES, and lockfile read order insrc/lockfile.rs(explicit env locks still beat auto ones)..miserc.toml, global config dir, and lockfile selection.docs/configuration/environments.md(the phase-2 warning links to its anchor), pointer indocs/configuration.md, and the settings reference renders fromsettings.toml.🤖 Generated with Claude Code
Note
Medium Risk
Changes which config and lockfiles load for projects that already have platform-named files; rollout is gated and opt-out exists, but mistaken enablement could shift tool versions and env vars.
Overview
Adds
auto_env, an early-init setting (MISE_AUTO_ENVor.miserc.toml) that, when enabled, automatically loads platform-specific config environments (unix,{os},{os}-{arch}) so files likemise.windows.tomland matchingmise.<env>.lockfiles participate in discovery without settingMISE_ENV. Precedence is platform envs first (least → most specific), then explicitMISE_ENV; auto envs are not reflected inMISE_ENVor{{ mise_env }}.Config filename enumeration is centralized via
env_config_patternsandMISE_ENV_WITH_AUTO; lockfile reads include auto platform locks after explicit env locks. Phased rollout: off by default now; version-gated one-time warning (2026.12.0–2027.5.x) when unset platform configs exist; default-on at 2027.6.0.Docs, JSON schemas,
settings.toml, e2e tests for config/lockfile behavior, and unit tests for warning/version logic accompany the Rust changes inenv.rs,miserc.rs,config/mod.rs, andlockfile.rs.Reviewed by Cursor Bugbot for commit 3da8ce1. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Documentation
Tests
Chores