Skip to content

Conversation

@ceelian
Copy link
Contributor

@ceelian ceelian commented Nov 18, 2025

Description

This PR ensures that the MISE_ENV environment variable is properly set in spawned shells when using the mise exec and mise encommand with the -E flag to specify an environment. This solves the issue in the discussion #6928

Changes

  • Modified src/cli/exec.rs to check if MISE_ENV is set (via the -E flag) and ensure it's included in the environment variables passed to the spawned shell
  • Added new e2e test e2e/cli/test_en_mise_env to verify the behavior

Problem

When using mise exec -E <env> -- <command>, the MISE_ENV variable was not being propagated to the spawned shell environment, making it difficult for scripts to know which mise environment context they're running in. This also applied to the mise -E <env> en command, the command that made me aware of the issue.

Solution

After building the environment with env_with_path(), we now check if MISE_ENV is set (populated by the -E flag) and explicitly add it to the environment map before spawning the shell.

// Ensure MISE_ENV is set in the spawned shell if it was specified via -E flag
if !env::MISE_ENV.is_empty() {
    env.insert("MISE_ENV".to_string(), env::MISE_ENV.join(","));
}

Testing

Added comprehensive e2e test that verifies MISE_ENV is properly set when using mise -E <env> en.


Note

Ensure MISE_ENV is passed to spawned shells for exec/en when specified via -E, and add e2e tests validating propagation and precedence.

  • CLI/Exec:
    • In src/cli/exec.rs, after building env with env_with_path, explicitly insert MISE_ENV (comma-joined) into the spawned shell env when provided via -E.
  • E2E Tests:
    • Add e2e/cli/test_en_mise_env covering:
      • MISE_ENV visibility in spawned shell and config discovery for env-specific files.
      • Env var loading/overrides for dev and staging, including multiple envs with order precedence.
      • Behavior without -E (no MISE_ENV, only base config applied).

Written by Cursor Bugbot for commit 913eec2. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings November 18, 2025 19:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the issue where the MISE_ENV environment variable was not being propagated to spawned shells when using the -E flag to specify an environment. The fix ensures that scripts running in the spawned shell can determine which mise environment context they're operating in.

Key Changes

  • Modified src/cli/exec.rs to explicitly set MISE_ENV in the spawned shell environment after building the environment map
  • Added comprehensive e2e test suite (test_en_mise_env) to verify the behavior with single and multiple environments

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/cli/exec.rs Adds logic to insert MISE_ENV into the environment map when it's non-empty, ensuring the variable is available in spawned shells
e2e/cli/test_en_mise_env Comprehensive test suite with 16 test cases covering single environments, multiple environments, environment-specific config loading, and variable precedence

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@autofix-ci
Copy link
Contributor

autofix-ci bot commented Nov 18, 2025

Hi! I'm autofix logoautofix.ci, a bot that automatically fixes trivial issues such as code formatting in pull requests.

I would like to apply some automated changes to this pull request, but it looks like I don't have the necessary permissions to do so. To get this pull request into a mergeable state, please do one of the following two things:

  1. Allow edits by maintainers for your pull request, and then re-trigger CI (for example by pushing a new commit).
  2. Manually fix the issues identified for your pull request (see the GitHub Actions output for details on what I would like to change).

@jdx
Copy link
Owner

jdx commented Nov 18, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


@jdx jdx enabled auto-merge (squash) November 18, 2025 23:23
@jdx jdx merged commit 25cf73d into jdx:main Nov 18, 2025
28 checks passed
jdx pushed a commit that referenced this pull request Nov 20, 2025
### 📦 Registry

- added nelm by @tony-sol in
[#7020](#7020)

### 🚀 Features

- **(exec)** ensure MISE_ENV is set in spawned shell when specified via
-E flag by @ceelian in [#7007](#7007)

### 🐛 Bug Fixes

- **(go)** Don't allow auto mod=vendor mode by @mariduv in
[#7006](#7006)
- **(nushell)** test `use` not `source`, fix pipeline parse error by
@jokeyrhyme in [#7013](#7013)
- **(tasks)** make file paths relative to config location and
templateable by @halms in [#7005](#7005)

### Chore

- **(deny)** add exclusion for number_prefix by @jdx in
[e955ecb](e955ecb)

### New Contributors

- @mariduv made their first contribution in
[#7006](#7006)
- @ceelian made their first contribution in
[#7007](#7007)

## 📦 Aqua Registry Updates

#### New Packages (2)

- [`blender/blender`](https://github.com/blender/blender)
- [`werf/werf`](https://github.com/werf/werf)

#### Updated Packages (1)

- [`mas-cli/mas`](https://github.com/mas-cli/mas)
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