fix: duplicate versions and validation in mise tool#6001
Conversation
- Fixed duplicate version display when a tool version is both current and installed The issue was in list_installed_versions() pushing versions twice - Added proper error handling for invalid tool names - Added HashSet deduplication as extra safeguard against duplicates - Created comprehensive e2e tests for the tool command Fixes reported issues: - 'mise tool opentofu' showing same version twice in installed versions - 'mise tool INVALID' not erroring out properly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes two issues in the mise tool command: duplicate version display and lack of error handling for invalid tool names. The changes ensure proper validation and deduplication of tool versions.
- Fixed duplicate version display by adding proper conditional logic in version listing
- Added validation to return errors for invalid/non-existent tool names
- Created comprehensive end-to-end tests to verify the fixes
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/toolset/mod.rs | Fixed duplicate version logic by adding else clause to prevent double-adding versions |
| src/cli/tool.rs | Added backend validation and HashSet deduplication for installed versions |
| e2e/cli/test_tool | Added comprehensive tests for invalid tools and duplicate version scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| .await?; | ||
| versions.push((b.clone(), tv)); | ||
| } | ||
| } |
There was a problem hiding this comment.
There appears to be a misplaced closing brace. This brace seems to close the outer loop prematurely, which would prevent processing of subsequent backends. The brace should likely be moved to after line 511 to properly close the inner loop iteration.
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.8.8 x -- echo |
17.9 ± 0.2 | 17.5 | 21.3 | 1.00 |
mise x -- echo |
18.0 ± 0.3 | 17.5 | 21.6 | 1.00 ± 0.02 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.8.8 env |
17.4 ± 0.2 | 17.0 | 20.1 | 1.00 |
mise env |
17.6 ± 0.6 | 16.9 | 24.6 | 1.01 ± 0.04 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.8.8 hook-env |
17.0 ± 0.2 | 16.3 | 18.5 | 1.00 |
mise hook-env |
17.1 ± 0.2 | 16.7 | 18.3 | 1.01 ± 0.02 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2025.8.8 ls |
15.9 ± 0.2 | 15.3 | 17.0 | 1.03 ± 0.01 |
mise ls |
15.5 ± 0.1 | 14.8 | 16.0 | 1.00 |
xtasks/test/perf
| Command | mise-2025.8.8 | mise | Variance |
|---|---|---|---|
| install (cached) | 186ms | ✅ 101ms | +84% |
| ls (cached) | 79ms | ✅ 60ms | +31% |
| bin-paths (cached) | 63ms | 64ms | -1% |
| task-ls (cached) | 474ms | 463ms | +2% |
✅ Performance improvement: install cached is 84%
✅ Performance improvement: ls cached is 31%
mise tool
### 📦 Registry - add vfox-yarn as primary yarn backend by [@jdx](https://github.com/jdx) in [#5982](#5982) - add missing description field for a lot of tools by [@jylenhof](https://github.com/jylenhof) in [#5966](#5966) - rename benthos to redpanda-connect by [@risu729](https://github.com/risu729) in [#5984](#5984) - rename coq to rocq by [@risu729](https://github.com/risu729) in [#5985](#5985) ### 🚀 Features - **(timeout)** show duration, URL, and config hint on timeouts; increase fetch timeout default to 10s by [@jdx](https://github.com/jdx) in [#5991](#5991) ### 🐛 Bug Fixes - **(aqua)** add executable permissions for zip-extracted binaries by [@itochan](https://github.com/itochan) in [#5998](#5998) - **(core)** auto-repair corrupted pyenv cache by recloning on update failure by [@jdx](https://github.com/jdx) in [#6003](#6003) - duplicate versions and validation in `mise tool` by [@jdx](https://github.com/jdx) in [#6001](#6001) ### 📚 Documentation - **(tools)** document per-tool postinstall option in [tools] by [@jdx](https://github.com/jdx) in [#5993](#5993) - Update install instructions for nushell by [@Joniator](https://github.com/Joniator) in [#5981](#5981) - README.md typo by [@jdx](https://github.com/jdx) in [#5990](#5990) ###◀️ Revert - Revert "docs: Update install instructions for nushell" by [@jdx](https://github.com/jdx) in [#5983](#5983) - Revert "fix(aqua): add executable permissions for zip-extracted binaries" by [@jdx](https://github.com/jdx) in [#6004](#6004) ### 📦️ Dependency Updates - update taiki-e/install-action digest to 2c73a74 by [@renovate[bot]](https://github.com/renovate[bot]) in [#5962](#5962) - update docker/metadata-action digest to c1e5197 by [@renovate[bot]](https://github.com/renovate[bot]) in [#5961](#5961) - update docker/login-action digest to 184bdaa by [@renovate[bot]](https://github.com/renovate[bot]) in [#5958](#5958) ### Chore - cargo up by [@jdx](https://github.com/jdx) in [#5992](#5992) ### New Contributors - @Joniator made their first contribution in [#5981](#5981) - @jylenhof made their first contribution in [#5966](#5966)
Summary
mise toolcommand when a tool version is both current and installedProblem
mise tool opentofuwas showing the same version twice in installed versions (e.g., "1.10.2 1.10.2")mise tool INVALIDwasn't returning an error when given an invalid tool nameSolution
Fixed duplicate versions: The root cause was in
src/toolset/mod.rs:list_installed_versions()where versions were being pushed to the result vector twice - once for current versions and then unconditionally. Added anelseclause to only create and push new ToolVersion when it's not already a current version.Fixed error handling: Modified
src/cli/tool.rsto properly validate that a backend exists and return an error for invalid tools that aren't configured.Added HashSet deduplication: As an extra safeguard, added HashSet-based deduplication in the tool command to ensure no duplicates are displayed.
Test plan
e2e/cli/test_tool) that verifies:mise tool opentofuandmise tool INVALID🤖 Generated with Claude Code