fix(tasks): restore MISE_ENV environment inheritance for tasks#6621
fix(tasks): restore MISE_ENV environment inheritance for tasks#6621
Conversation
| let config_env_entries = task_cf.env_entries()?; | ||
| // Get env entries from ALL config files (including MISE_ENV-specific ones) | ||
| // not just the task's config file | ||
| let all_config_env_entries: Vec<(crate::config::env_directive::EnvDirective, PathBuf)> = |
There was a problem hiding this comment.
To be clear — I'm not an expert on Mise's internal data structures and I don't really know that this is the right fix, but it does appear to fix the bug reported at https://github.com/blixt/mise-env-bug-repro and the test file looks good to me.
| // Early return if no special context needed | ||
| if self.should_use_standard_env_resolution(task, task_cf, config, &config_env_entries) { | ||
| // Check using task_cf entries for compatibility with existing logic | ||
| let task_cf_env_entries = task_cf.env_entries()?; |
There was a problem hiding this comment.
Definitely at least slightly skeptical of the idea that this call down here needs to use a simpler data structure than the main env resolution, but I don't really know what's going on here!
|
bugbot run |
|
It does look like this broke a few tests. Will look into that. |
Tasks with config file context were not inheriting environment variables from MISE_ENV-specific config files due to only loading env entries from the task's specific config file instead of all config files in the hierarchy. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
0b54fab to
05d8d4f
Compare
|
bugbot run |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where tasks were not properly inheriting environment variables from MISE_ENV-specific config files. The issue occurred because task environment resolution was only loading env entries from the task's specific config file instead of considering all config files in the hierarchy.
- Refactored task environment resolution to distinguish between monorepo tasks and regular tasks
- For regular tasks, now loads environment entries from all config files (including MISE_ENV-specific ones)
- Removed the now-unused
build_config_env_directiveshelper function
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/cli/run.rs | Updated task environment resolution logic to properly inherit MISE_ENV environment variables for regular tasks while preserving existing behavior for monorepo tasks |
| e2e/tasks/test_task_mise_env_profiles | Added comprehensive test coverage for MISE_ENV environment inheritance in tasks |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if self.should_use_standard_env_resolution(task, task_cf, config, &config_env_entries) { | ||
| // Check using task_cf entries for compatibility with existing logic | ||
| let task_cf_env_entries = task_cf.env_entries()?; | ||
| if self.should_use_standard_env_resolution(task, task_cf, config, &task_cf_env_entries) { |
There was a problem hiding this comment.
Bug: Config File Mismatch Causes Environment Inconsistency
The early return condition in resolve_task_env_with_config uses only the task's config file entries to decide if standard environment resolution is sufficient. However, the main processing logic considers entries from all relevant config files. This mismatch can cause inconsistent environment resolution, potentially affecting MISE_ENV inheritance for regular tasks.
Tasks with config file context were not inheriting environment variables from MISE_ENV-specific config files due to only loading env entries from the task's specific config file instead of all config files in the hierarchy.
🤖 Generated with Claude Code
Note
Restores MISE_ENV env inheritance for tasks by resolving env from all config files for regular tasks (while preserving monorepo behavior) and adds e2e tests covering profiles and override precedence.
config_files(including MISE_ENV-specific files) rather than only the task's config; keep original behavior for monorepo tasks.task_cf.env_entries(); reusets.full_envand apply resolved env, then task-specific env.(EnvDirective, PathBuf)and refactor to pass aggregated entries directly toresolve_env_directives.e2e/tasks/test_task_mise_env_profilesverifying:MISE_ENV.production,staging) and comma-separated precedence.MISE_ENVvalues.Written by Cursor Bugbot for commit 05d8d4f. This will update automatically on new commits. Configure here.