Skip to content

fix(task): auto-install tools from mise.toml for file tasks#8030

Merged
jdx merged 3 commits intomainfrom
fix/file-task-auto-install
Feb 6, 2026
Merged

fix(task): auto-install tools from mise.toml for file tasks#8030
jdx merged 3 commits intomainfrom
fix/file-task-auto-install

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Feb 6, 2026

Summary

  • When running file tasks (scripts in .mise-tasks/), tools defined in mise.toml were not auto-installed before execution because t.cf(config) returns None for file tasks
  • Adds a fallback that uses the task's config_root to discover and install tools from the project's config hierarchy, matching what the execution-time toolset build already does
  • Refactors collect_tools_from_config_file to delegate to a new collect_tools_from_dir method for reuse

Closes #8014

Test plan

  • mise run build compiles successfully
  • mise run lint-fix passes all linting
  • mise run test:unit — all 446 tests pass
  • Manual test: create a file task in .mise-tasks/ that uses a tool declared only in mise.toml, verify mise run auto-installs the tool before execution

🤖 Generated with Claude Code


Note

Medium Risk
Changes task tool resolution behavior by expanding when project config hierarchy is consulted, which could affect tool selection/precedence for some task setups; covered by a new E2E regression test.

Overview
Fixes task_run_auto_install for file tasks (scripts in mise-tasks/) by falling back to the task’s config_root to load the project config hierarchy when t.cf(config) is None, ensuring tools in mise.toml are discovered and installed before execution.

Refactors tool discovery by extracting shared logic into collect_tools_from_dir, and adds an E2E test (e2e/tasks/test_task_file_auto_install) that runs a file task requiring tiny and asserts it gets auto-installed.

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

When running file tasks (scripts in .mise-tasks/), tools defined in
mise.toml were not auto-installed before execution because file tasks
have no associated config file (t.cf() returns None). This adds a
fallback that uses the task's config_root to discover and install tools
from the project's config hierarchy, matching what the execution-time
toolset build already does.

Closes #8014

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 6, 2026 13:45
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 auto-installation of tools for file-based tasks (scripts in .mise-tasks/) by ensuring tools defined in mise.toml are discovered and installed before task execution. Previously, file tasks would fail to auto-install tools because they don't have a config file reference.

Changes:

  • Added fallback logic to use config_root for discovering tools when file tasks lack a config file reference
  • Refactored collect_tools_from_config_file to extract directory-based tool collection into a reusable collect_tools_from_dir method
  • Added documentation explaining the fallback behavior for file tasks

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jdx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug preventing file-based tasks from correctly auto-installing tools defined in mise.toml. By implementing a robust fallback using the task's config_root and refactoring tool collection logic, it ensures that all necessary tools are consistently discovered and installed, thereby enhancing the reliability and predictability of task execution within mise.

Highlights

  • File Task Tool Installation Fix: Corrects an issue where tools specified in mise.toml were not automatically installed for file tasks (scripts located in .mise-tasks/) prior to their execution.
  • Config Root Fallback: Introduces a fallback mechanism that utilizes the task's config_root to locate and install tools from the project's configuration hierarchy, aligning with the existing execution-time toolset build process.
  • Code Refactoring: Refactors the collect_tools_from_config_file method to delegate its core logic to a newly introduced collect_tools_from_dir method, promoting code reuse and maintainability.
Changelog
  • src/task/task_tool_installer.rs
    • Added std::path::Path import for path manipulation.
    • Modified the tool collection logic to include a fallback for file tasks, using config_root to find and install tools from the project's configuration hierarchy when a direct task config file is not present.
    • Refactored collect_tools_from_config_file to call a new helper function, collect_tools_from_dir, which encapsulates the logic for gathering tools from configuration files within a given directory hierarchy.
    • Introduced the collect_tools_from_dir asynchronous function to abstract the process of loading config hierarchies and extracting tool requests from a specified directory.
Activity
  • The pull request addresses and closes the discussion at https://github.com/jdx/mise/discussions/8014.
  • The author has performed unit tests (mise run test:unit) and linting (mise run lint-fix), and verified compilation (mise run build).
  • A manual test case is outlined, requiring verification that mise run auto-installs tools for file tasks declared only in mise.toml.
  • The PR description indicates that the code was generated with "Claude Code".
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 correctly fixes an issue where tools defined in mise.toml were not being auto-installed for file-based tasks. The change introduces a fallback mechanism to use the task's config_root to discover tools, which is the correct approach. Additionally, the refactoring of collect_tools_from_config_file into a more generic collect_tools_from_dir function is a great improvement for code reuse and clarity. I have one minor suggestion to further improve code readability by using an existing abstraction.

Comment on lines +69 to +70
let task_dir = task_cf.get_path().parent().unwrap_or(task_cf.get_path());
self.collect_tools_from_dir(task_dir, task_name).await
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using task_cf.config_root() is more idiomatic and concise for getting the directory of the config file. It achieves the same result as the current implementation but improves readability by using the existing abstraction for this purpose.

Suggested change
let task_dir = task_cf.get_path().parent().unwrap_or(task_cf.get_path());
self.collect_tools_from_dir(task_dir, task_name).await
let task_dir = task_cf.config_root();
self.collect_tools_from_dir(&task_dir, task_name).await

Verifies that tools defined in mise.toml are auto-installed before
running file tasks in mise-tasks/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.5 x -- echo 21.1 ± 0.5 20.1 23.8 1.00
mise x -- echo 21.6 ± 0.8 20.1 28.5 1.02 ± 0.05

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.5 env 20.6 ± 0.6 19.5 26.4 1.00
mise env 21.1 ± 1.3 19.5 36.2 1.03 ± 0.07

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.5 hook-env 21.1 ± 0.4 20.3 22.9 1.00
mise hook-env 21.4 ± 0.6 20.3 24.6 1.01 ± 0.03

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.2.5 ls 19.2 ± 0.5 18.4 20.7 1.00
mise ls 19.4 ± 0.7 18.4 25.7 1.01 ± 0.05

xtasks/test/perf

Command mise-2026.2.5 mise Variance
install (cached) 115ms 116ms +0%
ls (cached) 73ms 72ms +1%
bin-paths (cached) 77ms 78ms -1%
task-ls (cached) 538ms 547ms -1%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jdx jdx merged commit 03da54d into main Feb 6, 2026
35 checks passed
@jdx jdx deleted the fix/file-task-auto-install branch February 6, 2026 21:07
mise-en-dev added a commit that referenced this pull request Feb 7, 2026
### 🚀 Features

- **(env)** add shell-style variable expansion in env values by @jdx in
[#8029](#8029)
- **(list)** add --all-sources flag to list command by @TylerHillery in
[#8019](#8019)

### 🐛 Bug Fixes

- **(gem)** Windows support for gem backend by @my1e5 in
[#8031](#8031)
- **(gem)** revert gem.rs script newline change by @my1e5 in
[#8034](#8034)
- **(lock)** write tools to lockfile matching their source config by
@jdx in [#8012](#8012)
- **(ls)** sort sources deterministically in --all-sources output by
@jdx in [#8037](#8037)
- **(task)** auto-install tools from mise.toml for file tasks by @jdx in
[#8030](#8030)

### 📚 Documentation

- fix wrong positions of `mise run` flags by @muzimuzhi in
[#8036](#8036)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:copr docker digest to 3e00d7d by
@renovate[bot] in [#8023](#8023)
- update ghcr.io/jdx/mise:alpine docker digest to 0ced1b3 by
@renovate[bot] in [#8022](#8022)

### 📦 Registry

- add tirith
([github:sheeki03/tirith](https://github.com/sheeki03/tirith)) by
@sheeki03 in [#8024](#8024)
- add mas by @TyceHerrman in
[#8032](#8032)

### Security

- **(deps)** update time crate to 0.3.47 to fix RUSTSEC-2026-0009 by
@jdx in [#8026](#8026)

### New Contributors

- @sheeki03 made their first contribution in
[#8024](#8024)
- @TylerHillery made their first contribution in
[#8019](#8019)

## 📦 Aqua Registry Updates

#### New Packages (1)

-
[`kubernetes-sigs/kubectl-validate`](https://github.com/kubernetes-sigs/kubectl-validate)

#### Updated Packages (6)

-
[`flux-iac/tofu-controller/tfctl`](https://github.com/flux-iac/tofu-controller/tfctl)
- [`gogs/gogs`](https://github.com/gogs/gogs)
- [`j178/prek`](https://github.com/j178/prek)
- [`syncthing/syncthing`](https://github.com/syncthing/syncthing)
- [`tuist/tuist`](https://github.com/tuist/tuist)
- [`yaml/yamlscript`](https://github.com/yaml/yamlscript)
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
## Summary

- When running file tasks (scripts in `.mise-tasks/`), tools defined in
`mise.toml` were not auto-installed before execution because
`t.cf(config)` returns `None` for file tasks
- Adds a fallback that uses the task's `config_root` to discover and
install tools from the project's config hierarchy, matching what the
execution-time toolset build already does
- Refactors `collect_tools_from_config_file` to delegate to a new
`collect_tools_from_dir` method for reuse

Closes jdx#8014

## Test plan

- [x] `mise run build` compiles successfully
- [x] `mise run lint-fix` passes all linting
- [x] `mise run test:unit` — all 446 tests pass
- [ ] Manual test: create a file task in `.mise-tasks/` that uses a tool
declared only in `mise.toml`, verify `mise run` auto-installs the tool
before execution

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

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes task tool resolution behavior by expanding when project config
hierarchy is consulted, which could affect tool selection/precedence for
some task setups; covered by a new E2E regression test.
> 
> **Overview**
> Fixes `task_run_auto_install` for *file tasks* (scripts in
`mise-tasks/`) by falling back to the task’s `config_root` to load the
project config hierarchy when `t.cf(config)` is `None`, ensuring tools
in `mise.toml` are discovered and installed before execution.
> 
> Refactors tool discovery by extracting shared logic into
`collect_tools_from_dir`, and adds an E2E test
(`e2e/tasks/test_task_file_auto_install`) that runs a file task
requiring `tiny` and asserts it gets auto-installed.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7fce78f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
lucasew pushed a commit to lucasew/CONTRIB-mise that referenced this pull request Feb 18, 2026
### 🚀 Features

- **(env)** add shell-style variable expansion in env values by @jdx in
[jdx#8029](jdx#8029)
- **(list)** add --all-sources flag to list command by @TylerHillery in
[jdx#8019](jdx#8019)

### 🐛 Bug Fixes

- **(gem)** Windows support for gem backend by @my1e5 in
[jdx#8031](jdx#8031)
- **(gem)** revert gem.rs script newline change by @my1e5 in
[jdx#8034](jdx#8034)
- **(lock)** write tools to lockfile matching their source config by
@jdx in [jdx#8012](jdx#8012)
- **(ls)** sort sources deterministically in --all-sources output by
@jdx in [jdx#8037](jdx#8037)
- **(task)** auto-install tools from mise.toml for file tasks by @jdx in
[jdx#8030](jdx#8030)

### 📚 Documentation

- fix wrong positions of `mise run` flags by @muzimuzhi in
[jdx#8036](jdx#8036)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:copr docker digest to 3e00d7d by
@renovate[bot] in [jdx#8023](jdx#8023)
- update ghcr.io/jdx/mise:alpine docker digest to 0ced1b3 by
@renovate[bot] in [jdx#8022](jdx#8022)

### 📦 Registry

- add tirith
([github:sheeki03/tirith](https://github.com/sheeki03/tirith)) by
@sheeki03 in [jdx#8024](jdx#8024)
- add mas by @TyceHerrman in
[jdx#8032](jdx#8032)

### Security

- **(deps)** update time crate to 0.3.47 to fix RUSTSEC-2026-0009 by
@jdx in [jdx#8026](jdx#8026)

### New Contributors

- @sheeki03 made their first contribution in
[jdx#8024](jdx#8024)
- @TylerHillery made their first contribution in
[jdx#8019](jdx#8019)

## 📦 Aqua Registry Updates

#### New Packages (1)

-
[`kubernetes-sigs/kubectl-validate`](https://github.com/kubernetes-sigs/kubectl-validate)

#### Updated Packages (6)

-
[`flux-iac/tofu-controller/tfctl`](https://github.com/flux-iac/tofu-controller/tfctl)
- [`gogs/gogs`](https://github.com/gogs/gogs)
- [`j178/prek`](https://github.com/j178/prek)
- [`syncthing/syncthing`](https://github.com/syncthing/syncthing)
- [`tuist/tuist`](https://github.com/tuist/tuist)
- [`yaml/yamlscript`](https://github.com/yaml/yamlscript)
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