Skip to content

setup-wizard.sh calls log_debug before sourcing logging module #127

@trytofly94

Description

@trytofly94

Bug Description

The setup-wizard.sh script calls log_debug function on line 26 before the logging module is sourced, causing a "command not found" error.

Error Output

./src/setup-wizard.sh: line 26: log_debug: command not found

Root Cause

The script structure has:

  1. Line 26: log_debug "Loaded wizard module: $module" inside load_wizard_modules()
  2. Much later in the file: source "$SCRIPT_DIR/utils/logging.sh"

The function is called before the logging module that defines it is sourced.

Impact

  • Severity: Medium
  • Component: Setup Wizard
  • The setup wizard fails when running with --dry-run or other options
  • First-time setup experience is broken
  • May prevent users from properly configuring the system

Proposed Fix

Move the logging module source statement to the beginning of the file, right after the shebang and initial variable declarations, before any function definitions:

#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

# Load logging module first
if [[ -f "$SCRIPT_DIR/utils/logging.sh" ]]; then
    source "$SCRIPT_DIR/utils/logging.sh"
else
    echo "ERROR: Cannot find logging utilities" >&2
    exit 1  
fi

# Then continue with rest of the script...

Test Command to Reproduce

./src/setup-wizard.sh --dry-run

Environment

  • OS: macOS Darwin 24.6.0
  • Bash: 5.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions