mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix: correct WSL2 OS detection by removing PWD-based Windows override (#8869)
Signed-off-by: Jheison Martinez Bolivar <jheison.mb@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6e57d245d2
commit
59e9105c03
+4
-31
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user