feat(config): add .miserc.toml for early initialization settings#7596
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces .miserc.toml, a configuration file loaded during early initialization before main config files are parsed. The primary use case is setting MISE_ENV in a config file rather than only through environment variables or CLI arguments, enabling environment-specific configuration (e.g., mise.development.toml) to be selected via file-based settings.
Key changes:
- Adds
.miserc.tomlsupport with precedence: CLI args > env vars > .miserc.toml - New
ceiling_pathssetting to control config file search boundaries - Generates JSON schema for
.miserc.tomlvalidation
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/config/miserc.rs |
New module implementing .miserc.toml loading, merging, and accessor functions |
src/env.rs |
Updates lazy statics to fall back to .miserc.toml values when env vars are unset |
src/cli/mod.rs |
Initializes .miserc.toml early in CLI execution before accessing MISE_ENV |
settings.toml |
Marks eligible settings with rc = true flag and adds new ceiling_paths setting |
build.rs |
Generates MisercSettings struct from settings marked with rc = true |
xtasks/render/schema.ts |
Generates JSON schema for .miserc.toml filtering settings by rc = true |
schema/miserc.json |
Generated JSON schema for .miserc.toml validation |
schema/mise.json |
Updated with ceiling_paths setting and revised descriptions |
schema/mise-settings.json |
Adds rc field definition to settings schema |
e2e/config/test_miserc |
E2E test verifying .miserc.toml functionality and precedence rules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| for (const key in doc) { | ||
| const props = doc[key]; | ||
| if (hasSubkeys(props) && props.rc === true) { |
There was a problem hiding this comment.
The condition hasSubkeys(props) checks if props is a Props type with a type field, but then accesses props.rc directly. This creates a type mismatch because hasSubkeys is a type guard that narrows to Props, but Props doesn't include an rc field in its type definition. Add rc?: boolean to the Props type definition at the top of the file to match the actual usage.
| .unwrap_or_else(|_| PathBuf::from("/etc/mise")); | ||
| let system_path = system_dir.join("miserc.toml"); | ||
| if system_path.is_file() { | ||
| files.push(system_path); |
There was a problem hiding this comment.
The find_miserc_files function collects files in precedence order (highest first) but the calling code in load_miserc_settings iterates in reverse. Consider reversing the collection order here and removing the .rev() in the caller for clearer intent, or add a comment explaining why files are collected highest-first when they'll be processed lowest-first.
| MISE_ENV=ci assert "mise ls dummy" "dummy 1.1.0 (missing) ~/workdir/mise.toml 1" | ||
|
|
||
| # Test ceiling_paths in .miserc.toml - subdirectory should pick up parent miserc | ||
| rm -f .miserc.toml |
There was a problem hiding this comment.
The test removes .miserc.toml on line 17 and immediately recreates it on line 18 with identical content. This appears to be redundant—consider removing line 17 or clarifying with a comment if this serves a specific testing purpose.
| rm -f .miserc.toml |
8df6e1f to
16dc7c7
Compare
This adds support for .miserc.toml, a config file that is loaded very early in the initialization process, before the main config files are parsed. This allows setting MISE_ENV in a config file instead of only via environment variables or CLI args. Settings that can be set in .miserc.toml (marked with `rc = true` in settings.toml): - env - the primary use case for setting MISE_ENV - cd - change directory before loading config - ceiling_paths - where to stop searching for config files - ignored_config_paths - paths to skip during config discovery - override_config_filenames - override default config filenames - override_tool_versions_filenames - override .tool-versions filenames File locations (in order of precedence): 1. Local: .miserc.toml in cwd and ancestors 2. Global: ~/.config/mise/miserc.toml 3. System: /etc/mise/miserc.toml Precedence: CLI args > env vars > .miserc.toml Closes #XXXX Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.0 x -- echo |
19.5 ± 0.8 | 18.7 | 27.6 | 1.00 |
mise x -- echo |
19.6 ± 0.5 | 18.7 | 21.8 | 1.00 ± 0.05 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.0 env |
18.9 ± 0.4 | 18.1 | 21.9 | 1.00 |
mise env |
19.3 ± 0.9 | 18.3 | 26.9 | 1.02 ± 0.05 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.0 hook-env |
19.1 ± 0.4 | 18.4 | 22.8 | 1.00 |
mise hook-env |
19.3 ± 0.6 | 18.5 | 26.3 | 1.01 ± 0.04 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.1.0 ls |
17.3 ± 0.4 | 16.4 | 19.6 | 1.00 |
mise ls |
17.4 ± 0.8 | 16.6 | 27.3 | 1.01 ± 0.05 |
xtasks/test/perf
| Command | mise-2026.1.0 | mise | Variance |
|---|---|---|---|
| install (cached) | 109ms | 108ms | +0% |
| ls (cached) | 66ms | 66ms | +0% |
| bin-paths (cached) | 70ms | 70ms | +0% |
| task-ls (cached) | 276ms | 278ms | +0% |
Summary
.miserc.toml- a config file loaded very early in the initialization process, before main config files are parsedMISE_ENVin a config file instead of only via env vars or CLI argsrc = truein settings.toml can be set in .miserc.toml:env- the primary use case for setting MISE_ENVcd- change directory before loading configceiling_paths(new setting) - where to stop searching for config filesignored_config_paths- paths to skip during config discoveryoverride_config_filenames- override default config filenamesoverride_tool_versions_filenames- override .tool-versions filenamesFile locations (in order of precedence):
.miserc.tomlin cwd and ancestors~/.config/mise/miserc.toml/etc/mise/miserc.tomlPrecedence: CLI args > env vars > .miserc.toml
Also generates a JSON schema for .miserc.toml at
schema/miserc.json.Test plan
test_misercverifies:test_config_envtest continues to pass.miserc.tomlfiles🤖 Generated with Claude Code
Note
Enables early initialization via
.miserc.tomlso settings markedrc = true(e.g.,env,ceiling_paths,ignored_config_paths,override_*_filenames) can influence config discovery before main files load.src/config/miserc.rsto locate/merge.miserc.tomlfrom local→global→system;Cli::runloads it at startupenv.rsreads rc settings from miserc as fallback with precedence: CLI > env vars >.miserc.tomlbuild.rsemitsMisercSettings;xtasks/render/schema.tsgeneratesschema/miserc.jsonfromsettings.tomlentries withrc=trueceiling_pathssetting and mark applicable settings withrc=trueinsettings.toml; adjustschema/mise.json/mise-settings.jsonMISE_ENVvia.miserc.toml; new e2ee2e/config/test_misercvalidating behaviorWritten by Cursor Bugbot for commit 267fb20. This will update automatically on new commits. Configure here.