Skip to content

feat(config): report env files in config ls and doctor output#8853

Merged
jdx merged 1 commit intojdx:mainfrom
SamSoldatenko:report-env-files-in-config-ls
Apr 5, 2026
Merged

feat(config): report env files in config ls and doctor output#8853
jdx merged 1 commit intojdx:mainfrom
SamSoldatenko:report-env-files-in-config-ls

Conversation

@SamSoldatenko
Copy link
Copy Markdown
Contributor

@SamSoldatenko SamSoldatenko commented Apr 2, 2026

Settings-based env files (MISE_ENV_FILE / env_file setting) were previously invisible in all diagnostic outputs despite being loaded.

  • mise config ls now shows env files as rows in the main table with (none) in the Tools column; -v shows the env var keys they set
  • mise doctor now includes an env_files section in both text and JSON output
  • Settings env files are now loaded into EnvResults in load_env() so they are tracked with source paths, participate in cache invalidation, and are visible everywhere env_results is used
  • debug!() log line emitted per env file before EnvResults summary

Closes #8806

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 2, 2026

Greptile Summary

This PR makes settings-based env files (from MISE_ENV_FILE / env_file setting) visible in mise config ls and mise doctor output. Previously these files were silently loaded into the environment but invisible in all diagnostic commands.

Key changes:

  • load_env() now pushes Settings-based env files into env_results.env_files (with a dedup guard against files already loaded via _.file config directives) and records their key/value pairs with the file path as source, enabling consistent tracking across caching, watch_files, and display
  • mise config ls shows env files as additional table rows with (none) in the Tools column; -v shows the env var keys they export
  • mise doctor gains an env_files section in both text and JSON output
  • E2E test coverage added for both commands
  • The env_files field is removed from EnvResults's custom Debug impl; per-file debug!() lines in load_env() now cover Settings-sourced files

Confidence Score: 5/5

Safe to merge — changes are additive and the single redundant iterator chain is harmlessly deduplicated by BTreeSet

All remaining findings are P2 style suggestions; no correctness, data-integrity, or reliability issues found

src/config/mod.rs — the watch_files() function retains a redundant Settings::get().env_files() chain that can be cleaned up

Important Files Changed

Filename Overview
src/config/mod.rs load_env() now tracks Settings env files in env_results.env_files with dedup guard; watch_files() retains a now-redundant explicit Settings::get().env_files() chain that BTreeSet silently deduplicates
src/cli/config/ls.rs Appends env_files as table rows with (none) or verbose env-key list; JSON path emits empty tools array for env files
src/cli/doctor/mod.rs Adds env_files section to both text and JSON doctor output via new async render_env_files() helper; correctly shows (none) when no env files are configured
src/config/env_directive/mod.rs Removes env_files field from EnvResults custom Debug impl; all other fields and logic are unchanged
e2e/cli/test_config_ls Adds tests for MISE_ENV_FILE and _.file directives appearing as rows in config ls output, including verbose env-key display
e2e/cli/test_doctor Adds tests verifying env_files section is present in both text and JSON doctor output, with (none) and with a real env file

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI (config ls / doctor)
    participant Config as Config
    participant EnvResults as EnvResults
    participant Settings as Settings

    User->>CLI: mise config ls / mise doctor
    CLI->>Config: Config::get()
    Config-->>CLI: Arc<Config>
    CLI->>Config: config.env_results()
    Config->>Config: load_env() via OnceCell
    Config->>EnvResults: EnvResults::resolve(entries from _.file directives)
    loop EnvDirective::File
        EnvResults->>EnvResults: env_files.push(file)
        EnvResults->>EnvResults: env.insert(k, (v, file))
    end
    EnvResults-->>Config: EnvResults (env_files has _.file paths)
    Config->>Settings: Settings::get().env_files()
    Settings-->>Config: Vec<PathBuf> from MISE_ENV_FILE
    loop For each Settings env_file
        Config->>Config: skip if already in env_results.env_files
        Config->>Config: env_results.env_files.push(env_file)
        Config->>Config: env_results.env.insert(k, (v, env_file))
    end
    Config-->>CLI: and EnvResults (env_files = both sources unified)
    alt mise config ls
        CLI->>CLI: render config_files as table rows
        loop env_results.env_files
            CLI->>CLI: verbose: filter env keys by source == path
            CLI->>CLI: add row [display_path, keys or (none)]
        end
        CLI-->>User: table with env files appended
    else mise doctor
        CLI->>CLI: render_env_files → join paths or (none)
        CLI->>CLI: info::section(env_files)
        CLI-->>User: doctor output with env_files section
    end
Loading

Reviews (4): Last reviewed commit: "feat(config): report env files in config..." | Re-trigger Greptile

Comment thread src/cli/config/ls.rs
Comment thread src/config/env_directive/mod.rs
@SamSoldatenko SamSoldatenko force-pushed the report-env-files-in-config-ls branch from cd6a8df to fd69024 Compare April 2, 2026 16:47
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the environment file loading logic by moving it into the EnvResults::resolve process and updates the mise ls and mise doctor commands to include and display these environment files. The reviewer suggested using raw path strings instead of formatted display paths in the mise doctor JSON output to maintain consistency with other configuration fields.

Comment thread src/cli/doctor/mod.rs Outdated
@SamSoldatenko SamSoldatenko marked this pull request as draft April 2, 2026 16:51
@SamSoldatenko SamSoldatenko force-pushed the report-env-files-in-config-ls branch from fd69024 to a1830fd Compare April 5, 2026 16:42
Settings-based env files (MISE_ENV_FILE / env_file setting) were
previously invisible in all diagnostic outputs despite being loaded.

- `mise config ls` now shows env files as rows in the main table with
  (none) in the Tools column; `-v` shows the env var keys they set
- `mise doctor` now includes an env_files section in both text and JSON
  output
- Settings env files are now loaded into EnvResults in load_env() so
  they are tracked with source paths, participate in cache invalidation,
  and are visible everywhere env_results is used
- debug!() log line emitted per env file before EnvResults summary

Closes #8806

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SamSoldatenko SamSoldatenko force-pushed the report-env-files-in-config-ls branch from a1830fd to 853a873 Compare April 5, 2026 17:19
@SamSoldatenko SamSoldatenko marked this pull request as ready for review April 5, 2026 17:46
@SamSoldatenko
Copy link
Copy Markdown
Contributor Author

Hi @jdx, could you take a look this PR?

Copy link
Copy Markdown
Owner

@jdx jdx left a comment

Choose a reason for hiding this comment

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

(deleted)

@jdx jdx merged commit 9223640 into jdx:main Apr 5, 2026
34 checks passed
@SamSoldatenko SamSoldatenko deleted the report-env-files-in-config-ls branch April 5, 2026 19:32
mise-en-dev added a commit that referenced this pull request Apr 6, 2026
### 🚀 Features

- **(config)** report env files in config ls and doctor output by
@SamSoldatenko in [#8853](#8853)
- add support for token sources in GitLab and Forgejo by @roele in
[#8868](#8868)

### 🐛 Bug Fixes

- **(aqua)** prevent double .exe extension when Windows override URL
already ends in .exe by @yusei-wy in
[#8863](#8863)
- **(bash)** avoid duplicate trust warning after cd by @timothysparg in
[#8920](#8920)
- **(env)** prevent config root injection into PATH via _.source by @jdx
in [#8936](#8936)
- **(install)** suppress spurious dependency warning when tool is
configured by @jdx in [#8923](#8923)

### 📚 Documentation

- **(node)** add section on pinning npm version by @jdx in
[#8925](#8925)
- add Windows default paths and mise.toml examples alongside CLI
commands by @jdx in [#8926](#8926)
- clarify common sources of confusion from GitHub discussions by @jdx in
[#8927](#8927)
- clarify Python venv mechanisms, JAVA_HOME behavior, and activation
performance by @jdx in [#8928](#8928)
- add FAQ and troubleshooting entries based on common Discord questions
by @jdx in [#8930](#8930)

### New Contributors

- @SamSoldatenko made their first contribution in
[#8853](#8853)
- @yusei-wy made their first contribution in
[#8863](#8863)
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