Skip to content

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Nov 12, 2025

Summary

Previously, running mise help (without --help) would fail with "no tasks defined" error when no tasks were configured in the current directory. This happened because the help argument was being treated as a task name, triggering config loading and task resolution.

This PR fixes the issue by adding special handling for the "help" argument in two places:

  1. In the preprocessor, to prevent "help" from being converted to "run help"
  2. In get_command(), to exit early with help output for help-related args

Now mise help, mise --help, and mise -h all work consistently, regardless of whether tasks are configured.

Test plan

  • Added new e2e test e2e/cli/test_help_without_tasks that verifies all three help variants work in a directory without tasks
  • All existing unit and e2e tests pass
  • Manually tested mise help, mise --help, and mise -h in directories with and without tasks

Fixes #6947


🤖 Generated with Claude Code


Note

Treat help, --help, and -h as help invocation (not tasks) and add an e2e test validating behavior without tasks.

  • CLI:
    • Preprocessor: skip injecting run when first non-flag arg is help, -h, or --help in src/cli/mod.rs.
    • Command resolution: if TASK equals help, -h, or --help, print help and exit with code 0.
  • Tests:
    • Add e2e/cli/test_help_without_tasks to verify mise help, mise --help, and mise -h work in a directory without tasks.

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

Previously, running `mise help` (without `--help`) would fail with
"no tasks defined" error when no tasks were configured in the current
directory. This happened because the help argument was being treated
as a task name, triggering config loading and task resolution.

This fix adds special handling for the "help" argument in two places:
1. In the preprocessor, to prevent "help" from being converted to "run help"
2. In get_command(), to exit early with help output for help-related args

Now `mise help`, `mise --help`, and `mise -h` all work consistently,
regardless of whether tasks are configured.

Fixes #6947

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings November 12, 2025 23:54
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 a bug where running mise help (without the --help flag) would fail with a "no tasks defined" error when no tasks were configured. The issue occurred because "help" was being interpreted as a task name, triggering unnecessary config loading and task resolution.

Key Changes:

  • Added special case handling in the argument preprocessor to prevent "help" from being treated as a task name
  • Added early exit logic in get_command() to display help output when help-related arguments are detected
  • Added comprehensive e2e test coverage for all help command variants

Reviewed Changes

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

File Description
src/cli/mod.rs Added special case handling for help arguments in preprocessor and get_command() to prevent help from being treated as a task
e2e/cli/test_help_without_tasks New e2e test verifying mise help, mise --help, and mise -h work without task configuration

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

Comment on lines +475 to +476
// Handle special case: "help", "-h", or "--help" as task should print help
if task == "help" || task == "-h" || task == "--help" {
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The condition checks if task equals '-h' or '--help', but these flags would have been parsed by clap as CLI flags, not as task names. Only 'help' can reach this point as a task value. The additional checks for '-h' and '--help' are unreachable and should be removed.

Suggested change
// Handle special case: "help", "-h", or "--help" as task should print help
if task == "help" || task == "-h" || task == "--help" {
// Handle special case: "help" as task should print help
if task == "help" {

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +12
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

The cleanup section uses 'cd -' which assumes the previous directory is still in the directory stack. If the script fails before reaching cleanup, the temp directory won't be removed. Consider using a trap to ensure cleanup on exit: trap 'rm -rf \"$TEMP_DIR\"' EXIT

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.3 x -- echo 19.1 ± 0.9 18.2 27.7 1.00 ± 0.05
mise x -- echo 19.1 ± 0.4 18.2 20.6 1.00

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.3 env 18.3 ± 0.3 17.7 19.6 1.00
mise env 18.8 ± 0.7 17.7 23.4 1.03 ± 0.04

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.3 hook-env 18.4 ± 0.3 17.7 19.8 1.00
mise hook-env 18.7 ± 0.5 17.9 21.4 1.02 ± 0.03

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.11.3 ls 15.9 ± 0.3 15.4 17.7 1.00
mise ls 16.6 ± 0.6 15.6 18.5 1.05 ± 0.04

xtasks/test/perf

Command mise-2025.11.3 mise Variance
install (cached) 105ms 109ms -3%
ls (cached) 64ms 65ms -1%
bin-paths (cached) 71ms 71ms +0%
task-ls (cached) 425ms 434ms -2%

@jdx jdx merged commit a1da87b into main Nov 13, 2025
30 checks passed
@jdx jdx deleted the fix/help-command-task-error branch November 13, 2025 00:11
@jdx jdx restored the fix/help-command-task-error branch November 13, 2025 18:08
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