Skip to content

CLI Installation on Windows fails because of missing bzip2 install #4848

@rajbos

Description

@rajbos

Describe the bug
CLI Installation on Windows fails because of missing bzip2 install, which it should not use at all.

To Reproduce
Steps to reproduce the behavior:

  1. Execute curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | bash in PowerShell
  2. Error:
Downloading stable release: goose-x86_64-unknown-linux-gnu.tar.bz2...
Extracting goose-x86_64-unknown-linux-gnu.tar.bz2 to temporary directory...
Error: Failed to extract goose-x86_64-unknown-linux-gnu.tar.bz2. 'bzip2' is required but not installed. See details below:
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Expected behavior
Using the zip file instead of te bz2 file

Please provide following information:

  • OS & Arch: Windows 11
  • Interface: CLI
  • Version: v1.9.0

Additional context
I checked the install script and it tests the OS with:

uname -s
uname -m

Running that in the bash shell from the Git install will return Linux and ARCH x86_64, hence the choice for the wrong zip file and then using a tool that does not exist.

I changed the script's step 3 to detect the OS better, works on my machine, not sure what the impact on other OS'es will be:

# --- 3) Detect OS/Architecture ---
# Better OS detection for Windows environments
if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
    OS="windows"
elif [[ -f "/proc/version" ]] && grep -q "Microsoft\|WSL" /proc/version 2>/dev/null; then
    # WSL detection
    OS="windows"
elif [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then
    # WSL mount point detection (like /mnt/c/)
    OS="windows"
elif [[ "$OSTYPE" == "darwin"* ]]; then
    OS="darwin"
elif command -v powershell.exe >/dev/null 2>&1 || command -v cmd.exe >/dev/null 2>&1; then
    # Check if Windows executables are available (another Windows indicator)
    OS="windows"
elif [[ "$PWD" =~ ^/[a-zA-Z]/ ]] && [[ -d "/c" || -d "/d" || -d "/e" ]]; then
    # Check for Windows-style mount points (like in Git Bash)
    OS="windows"
else
    # Fallback to uname for other systems
    OS=$(uname -s | tr '[:upper:]' '[:lower:]')
fi

ARCH=$(uname -m)

# Debug output (safely handle undefined variables)
echo "WINDIR: ${WINDIR:-<not set>}"
echo "OSTYPE: $OSTYPE"
echo "uname -s: $(uname -s)"
echo "uname -m: $(uname -m)"
echo "PWD: $PWD"

# Handle Windows environments (MSYS2, Git Bash, Cygwin, WSL)
case "$OS" in
  linux|darwin|windows) ;;
  mingw*|msys*|cygwin*)
    OS="windows"
    ;;
  *)
    echo "Error: Unsupported OS '$OS'. Goose currently supports Linux, macOS, and Windows."
    exit 1
    ;;
esac

case "$ARCH" in
  x86_64)
    ARCH="x86_64"
    ;;
  arm64|aarch64)
    # Some systems use 'arm64' and some 'aarch64' – standardize to 'aarch64'
    ARCH="aarch64"
    ;;
  *)
    echo "Error: Unsupported architecture '$ARCH'."
    exit 1
    ;;
esac

# Output the detected OS
echo "Detected OS: $OS with ARCH $ARCH"

# Check for required extraction tools based on detected OS
if [ "$OS" = "windows" ]; then
  # Windows uses PowerShell's built-in Expand-Archive - check if PowerShell is available
  if ! command -v powershell.exe >/dev/null 2>&1 && ! command -v pwsh >/dev/null 2>&1; then
    echo "Error: PowerShell is required to extract Windows packages but was not found."
    echo "Please ensure PowerShell is installed and accessible."
    exit 1
  fi
else
  if ! command -v tar >/dev/null 2>&1; then
    echo "Error: 'tar' is required to extract packages for $OS. Please install tar and try again."
    exit 1
  fi
fi

I can send in a PR for that change if you want to, just can validate the impact on other OS-es, (if any).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions