From 59e9105c03e5d396d666ce17ddadb6bec948551b Mon Sep 17 00:00:00 2001 From: Jheison Martinez Bolivar <78370841+JheisonMB@users.noreply.github.com> Date: Mon, 11 May 2026 20:20:54 -0500 Subject: [PATCH] fix: correct WSL2 OS detection by removing PWD-based Windows override (#8869) Signed-off-by: Jheison Martinez Bolivar --- download_cli.sh | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/download_cli.sh b/download_cli.sh index c34afe8ad2..2d7c0d41f3 100755 --- a/download_cli.sh +++ b/download_cli.sh @@ -60,14 +60,8 @@ OUT_FILE="goose" if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then # Native Windows environments - use Windows user profile path DEFAULT_BIN_DIR="$USERPROFILE/goose" -elif [[ -f "/proc/version" ]] && grep -q "Microsoft\|WSL" /proc/version 2>/dev/null; then - # WSL - use Linux-style path but make sure it exists - DEFAULT_BIN_DIR="$HOME/.local/bin" -elif [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then - # WSL mount point detection - DEFAULT_BIN_DIR="$HOME/.local/bin" else - # Default for Linux/macOS + # Linux, macOS, and WSL all use the same bin directory DEFAULT_BIN_DIR="$HOME/.local/bin" fi @@ -103,32 +97,11 @@ else 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 detected. Prefer Linux unless there are clear signs we should install the Windows build: - # - running on a Windows-mounted path like /mnt/c/... OR - # - Windows executables are available AND we're on a Windows mount - if [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then - OS="windows" - else - # If powershell/cmd exist, only treat as Windows when in a Windows mount - if command -v powershell.exe >/dev/null 2>&1 || command -v cmd.exe >/dev/null 2>&1; then - if [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]] || [[ -d "/c" || -d "/d" || -d "/e" ]]; then - OS="windows" - else - OS="linux" - fi - else - # No strong Windows interop present — install Linux build inside WSL by default - OS="linux" - fi - fi - elif [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then - # WSL mount point detection (like /mnt/c/) outside of /proc/version check - OS="windows" + # WSL is a Linux environment regardless of the current working directory. + # The PWD (e.g. /mnt/c/) does not change the kernel — always install Linux. + OS="linux" elif [[ "$OSTYPE" == "darwin"* ]]; then OS="darwin" - elif command -v powershell.exe >/dev/null 2>&1 || command -v cmd.exe >/dev/null 2>&1; then - # Presence of Windows executables (likely a Windows environment) - 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"