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
|
if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
||||||
# Native Windows environments - use Windows user profile path
|
# Native Windows environments - use Windows user profile path
|
||||||
DEFAULT_BIN_DIR="$USERPROFILE/goose"
|
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
|
else
|
||||||
# Default for Linux/macOS
|
# Linux, macOS, and WSL all use the same bin directory
|
||||||
DEFAULT_BIN_DIR="$HOME/.local/bin"
|
DEFAULT_BIN_DIR="$HOME/.local/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -103,32 +97,11 @@ else
|
|||||||
if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
||||||
OS="windows"
|
OS="windows"
|
||||||
elif [[ -f "/proc/version" ]] && grep -q "Microsoft\|WSL" /proc/version 2>/dev/null; then
|
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:
|
# WSL is a Linux environment regardless of the current working directory.
|
||||||
# - running on a Windows-mounted path like /mnt/c/... OR
|
# The PWD (e.g. /mnt/c/) does not change the kernel — always install Linux.
|
||||||
# - Windows executables are available AND we're on a Windows mount
|
OS="linux"
|
||||||
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"
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
OS="darwin"
|
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
|
elif [[ "$PWD" =~ ^/[a-zA-Z]/ ]] && [[ -d "/c" || -d "/d" || -d "/e" ]]; then
|
||||||
# Check for Windows-style mount points (like in Git Bash)
|
# Check for Windows-style mount points (like in Git Bash)
|
||||||
OS="windows"
|
OS="windows"
|
||||||
|
|||||||
Reference in New Issue
Block a user