Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/cli/test_error_display
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ python = ["also", "not", "valid"]
EOF

local_assert_fail "MISE_CONFIG_FILE=test_invalid_config.toml mise install" \
"0: Failed to install tools: core:python@also, core:python@not, core:python@valid, core:node@this is not valid"
"0: Failed to install tools: core:node@this is not valid, core:python@also, core:python@not, core:python@valid"
rm -f test_invalid_config.toml

echo ""
Expand Down
22 changes: 12 additions & 10 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,28 @@ fn format_install_failures(failed_installations: &[(ToolRequest, Report)]) -> St
}

// For multiple failures, show a summary and then each error
// Sort by tool name for deterministic output (parallel installs complete in arbitrary order)
let mut sorted_failures: Vec<_> = failed_installations
.iter()
.map(|(tr, err)| (format!("{}@{}", tr.ba().full(), tr.version()), err))
.collect();
Comment on lines +64 to +67

Copilot AI Jan 31, 2026

Copy link

Choose a reason for hiding this comment

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

The tool name string is formatted twice: once here for sorting and again in the original loop. Consider storing the formatted string once to avoid redundant string allocations and formatting operations.

Copilot uses AI. Check for mistakes.
sorted_failures.sort_by(|a, b| a.0.cmp(&b.0));

let mut output = vec![];
let failed_tools: Vec<String> = failed_installations
let failed_tools: Vec<&str> = sorted_failures
.iter()
.map(|(tr, _)| format!("{}@{}", tr.ba().full(), tr.version()))
.map(|(name, _)| name.as_str())
.collect();

output.push(format!(
"Failed to install tools: {}",
failed_tools.join(", ")
));

// Show detailed errors for each failure
// Show detailed errors for each failure (in sorted order)
// Use {:#} to show full error chain (includes wrapped errors)
for (tr, error) in failed_installations.iter() {
output.push(format!(
"\n{}@{}: {:#}",
tr.ba().full(),
tr.version(),
error
));
for (name, error) in sorted_failures.iter() {
output.push(format!("\n{}: {:#}", name, error));
}

output.join("\n")
Expand Down
Loading