Skip to content

Conversation

stefanomainardi
Copy link
Member

@stefanomainardi stefanomainardi commented Oct 5, 2025

User description

Summary

  • Add support for Arch Linux (pacman), Ubuntu/Debian (apt), CentOS/RHEL (yum), and Fedora (dnf)
  • Replace generic "Homebrew not available" error with specific installation instructions
  • Provide clear guidance for manual installation across different Linux distributions

Problem

Currently, when mkcert is not installed on non-macOS systems, users get an unhelpful error message:

❌ mkcert not found and Homebrew not available for installation

This is particularly problematic on Arch Linux where mkcert is available via pacman, but users were only told about Homebrew.

Solution

The install_mkcert() function now:

  1. Checks for multiple package managers in order of preference
  2. Provides specific installation commands for each detected package manager
  3. Falls back to comprehensive manual installation instructions

Test plan

  • Tested on Arch Linux with pacman detection
  • Verified error messages are helpful and specific
  • Confirmed fallback behavior works correctly
  • Validated that existing Homebrew functionality is preserved

Example output on Arch Linux

ℹ  Installing mkcert with pacman...
ℹ  Please run: sudo pacman -S mkcert
❌ Automatic installation with pacman requires sudo privileges
ℹ  After installation, run the command again

PR Type

Enhancement


Description

  • Add support for multiple Linux package managers (pacman, apt, yum, dnf)

  • Replace generic Homebrew error with specific installation instructions

  • Provide comprehensive manual installation guidance for all distributions

  • Improve user experience with clear package manager detection


Changes walkthrough 📝

Relevant files
Enhancement
spark-http-proxy
Enhanced mkcert installation with multi-package manager support

bin/spark-http-proxy

  • Replace single Homebrew check with multi-package manager detection
  • Add support for pacman, apt, yum, and dnf package managers
  • Provide specific installation commands for each detected manager
  • Add comprehensive fallback manual installation instructions
  • +40/-9   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • - Add support for Arch Linux (pacman), Ubuntu/Debian (apt), CentOS/RHEL (yum), and Fedora (dnf)
    - Replace generic "Homebrew not available" error with specific installation instructions
    - Provide clear guidance for manual installation across different Linux distributions
    - Improve user experience when mkcert is not installed
    
    Fixes the issue where Arch Linux users would get an unhelpful error message
    about Homebrew not being available, even though mkcert is available via pacman.
    @sparkfabrik-ai-bot
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Issue

    The function has unreachable code after line 436. The return 1 statement will never be executed because all previous conditions end with return statements, making the final else block unreachable.

      return 1
    else
      log_error "mkcert not found and no supported package manager available"
      log_info "Please install mkcert manually:"
      log_info "  - Arch Linux: sudo pacman -S mkcert"
      log_info "  - Ubuntu/Debian: sudo apt install mkcert"
      log_info "  - CentOS/RHEL: sudo yum install mkcert"
      log_info "  - Fedora: sudo dnf install mkcert"
      log_info "  - macOS: brew install mkcert"
      return 1
    fi
    Inconsistent Behavior

    Only Homebrew performs automatic installation, while all other package managers just display instructions and return error code 1. This creates inconsistent user experience across different systems.

    if command -v brew >/dev/null 2>&1; then
      log_info "Installing mkcert with Homebrew..."
      if brew install mkcert nss && mkcert -install; then
        log_success "mkcert installed successfully"
        return 0
      else
        log_error "Failed to install mkcert with Homebrew"
        return 1
      fi
    elif command -v pacman >/dev/null 2>&1; then
      log_info "Installing mkcert with pacman..."
      log_info "Please run: sudo pacman -S mkcert"
      log_error "Automatic installation with pacman requires sudo privileges"
      log_info "After installation, run the command again"
      return 1
    elif command -v apt >/dev/null 2>&1; then
      log_info "Installing mkcert with apt..."
      log_info "Please run: sudo apt install mkcert"
      log_error "Automatic installation with apt requires sudo privileges"
      log_info "After installation, run the command again"
      return 1
    elif command -v yum >/dev/null 2>&1; then
      log_info "Installing mkcert with yum..."
      log_info "Please run: sudo yum install mkcert"
      log_error "Automatic installation with yum requires sudo privileges"
      log_info "After installation, run the command again"
      return 1
    elif command -v dnf >/dev/null 2>&1; then
      log_info "Installing mkcert with dnf..."
      log_info "Please run: sudo dnf install mkcert"
      log_error "Automatic installation with dnf requires sudo privileges"
      log_info "After installation, run the command again"

    @sparkfabrik-ai-bot
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Separate installation from CA setup

    The mkcert -install command should be executed after verifying the installation was
    successful, not as part of the same conditional. This prevents potential issues if
    the installation succeeds but the CA setup fails.

    bin/spark-http-proxy [406-412]

    -if brew install mkcert nss && mkcert -install; then
    -  log_success "mkcert installed successfully"
    -  return 0
    +if brew install mkcert nss; then
    +  log_info "mkcert installed, setting up root CA..."
    +  if mkcert -install; then
    +    log_success "mkcert installed successfully"
    +    return 0
    +  else
    +    log_error "Failed to setup mkcert root CA"
    +    return 1
    +  fi
     else
       log_error "Failed to install mkcert with Homebrew"
       return 1
     fi
    Suggestion importance[1-10]: 8

    __

    Why: This addresses a potential issue where mkcert -install failure could be masked by successful package installation. Separating these operations provides better error handling and clearer feedback to users.

    Medium
    Consolidate repetitive package manager code

    The repetitive code for different package managers can be consolidated into a more
    maintainable structure. Consider using an array-based approach to reduce duplication
    and make it easier to add new package managers.

    bin/spark-http-proxy [413-436]

    -elif command -v pacman >/dev/null 2>&1; then
    -  log_info "Installing mkcert with pacman..."
    -  log_info "Please run: sudo pacman -S mkcert"
    -  log_error "Automatic installation with pacman requires sudo privileges"
    -  log_info "After installation, run the command again"
    -  return 1
    -elif command -v apt >/dev/null 2>&1; then
    -  log_info "Installing mkcert with apt..."
    -  log_info "Please run: sudo apt install mkcert"
    -  log_error "Automatic installation with apt requires sudo privileges"
    -  log_info "After installation, run the command again"
    -  return 1
    -elif command -v yum >/dev/null 2>&1; then
    -  log_info "Installing mkcert with yum..."
    -  log_info "Please run: sudo yum install mkcert"
    -  log_error "Automatic installation with yum requires sudo privileges"
    -  log_info "After installation, run the command again"
    -  return 1
    -elif command -v dnf >/dev/null 2>&1; then
    -  log_info "Installing mkcert with dnf..."
    -  log_info "Please run: sudo dnf install mkcert"
    -  log_error "Automatic installation with dnf requires sudo privileges"
    -  log_info "After installation, run the command again"
    -  return 1
    +else
    +  # Array of package managers with their install commands
    +  declare -a pkg_managers=(
    +    "pacman:sudo pacman -S mkcert"
    +    "apt:sudo apt install mkcert"
    +    "yum:sudo yum install mkcert"
    +    "dnf:sudo dnf install mkcert"
    +  )
    +  
    +  for pm_info in "${pkg_managers[@]}"; do
    +    pm_cmd="${pm_info%%:*}"
    +    install_cmd="${pm_info#*:}"
    +    if command -v "$pm_cmd" >/dev/null 2>&1; then
    +      log_info "Installing mkcert with $pm_cmd..."
    +      log_info "Please run: $install_cmd"
    +      log_error "Automatic installation with $pm_cmd requires sudo privileges"
    +      log_info "After installation, run the command again"
    +      return 1
    +    fi
    +  done
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies code duplication and provides a cleaner array-based approach. This improves maintainability and reduces repetition, though it's a moderate improvement rather than fixing a critical issue.

    Medium

    log_info "Installing mkcert with dnf..."
    log_info "Please run: sudo dnf install mkcert"
    log_error "Automatic installation with dnf requires sudo privileges"
    log_info "After installation, run the command again"
    Copy link
    Member

    Choose a reason for hiding this comment

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

    I would keep Brew and Pacman, as they are the only distributions we support now.
    For arch we neeed to install both packages: pacman -S nss mkcert

    As we do for brew, we can actually run the command instead of just printing.

    @stefanomainardi

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants