Skip to content

Include color output in build error messages during dev mode #23

Description

@brooksmtownsend

Description

When component builds fail during development mode, the error output doesn't include color formatting. This makes it harder to read and parse error messages compared to running builds directly.

Location

crates/wash/src/cli/dev.rs:345 in the rebuild error handling

Current Behavior

Err(e) => {
    info!("failed to build component, will retry on next file change");
    // TODO(GFI): This doesn't include color output
    // This nicely formats the error message
    error!("{e}");
    // ...
}

The error output lacks color formatting that would normally be present when running build tools directly.

Proposed Solution

Preserve color formatting in error output:

  1. Capture colored output: Ensure build processes preserve terminal color codes
  2. Pass through colors: Don't strip ANSI color codes when displaying errors
  3. Terminal detection: Respect user's color preferences and terminal capabilities

Example Implementation

Err(e) => {
    info!("failed to build component, will retry on next file change");
    
    // Preserve color output if terminal supports it
    if atty::is(atty::Stream::Stderr) {
        // Display with colors preserved
        eprintln!("{}", e);
    } else {
        // Fallback to plain text for non-terminals
        error!("{e}");
    }
    // ...
}

Benefits

  • Better readability: Color-coded errors are easier to scan and understand
  • Consistent experience: Matches what users see when running builds directly
  • Error highlighting: Syntax errors, warnings, and suggestions are properly highlighted

Implementation Notes

  • Should respect NO_COLOR environment variable
  • Consider using termcolor or similar crate for cross-platform support
  • May need to configure build tools to output colors even when not in TTY mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions