Skip to content

Conversation

@aegntic
Copy link
Contributor

@aegntic aegntic commented Oct 1, 2025

  • Enhanced Windows detection for Git Bash, MSYS2, Cygwin, and WSL environments
  • Added multiple detection methods: WINDIR, OSTYPE, /proc/version, mount points, Windows executables
  • Fixed issue where Git Bash on Windows incorrectly detected as Linux
  • Added debug output to help troubleshoot OS detection issues
  • Improved extraction tool validation based on detected OS
  • Fixes CLI Installation on Windows fails because of missing bzip2 install #4848 where CLI installation failed due to downloading Linux tar.bz2 instead of Windows zip

Closes #4848

Pull Request Description


Email:

Copy link
Contributor

@Kvadratni Kvadratni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! every improvement is welcome

@DOsinga
Copy link
Collaborator

DOsinga commented Oct 6, 2025

thanks @aegntic - can you do the DCO thing so we can get this merged?

Copy link
Contributor Author

@aegntic aegntic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't change the people around you, but you can change the people around you.

- Enhanced Windows detection for Git Bash, MSYS2, Cygwin, and WSL environments
- Added multiple detection methods: WINDIR, OSTYPE, /proc/version, mount points, Windows executables
- Fixed issue where Git Bash on Windows incorrectly detected as Linux
- Added debug output to help troubleshoot OS detection issues
- Improved extraction tool validation based on detected OS
- Fixes block#4848 where CLI installation failed due to downloading Linux tar.bz2 instead of Windows zip

Closes block#4848

Signed-off-by: aegntic <[email protected]>

diff --git a/download_cli.sh b/download_cli.sh
index 2131924..107d3e7 100755
--- a/download_cli.sh
+++ b/download_cli.sh
@@ -36,6 +36,20 @@ if ! command -v tar >/dev/null 2>&1 && ! command -v unzip >/dev/null 2>&1; then
   exit 1
 fi

+# 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 "Warning: PowerShell is recommended to extract Windows packages but was not found."
+    echo "Falling back to unzip if available."
+  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
+

 # --- 2) Variables ---
 REPO="block/goose"
@@ -58,12 +72,33 @@ else
 fi

 # --- 3) Detect OS/Architecture ---
-OS=$(uname -s | tr '[:upper:]' '[:lower:]')
+# 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)

 # Handle Windows environments (MSYS2, Git Bash, Cygwin, WSL)
 case "$OS" in
-  linux|darwin) ;;
+  linux|darwin|windows) ;;
   mingw*|msys*|cygwin*)
     OS="windows"
     ;;
@@ -87,6 +122,16 @@ case "$ARCH" in
     ;;
 esac

+# 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"
+
+# Output the detected OS
+echo "Detected OS: $OS with ARCH $ARCH"
+
 # Build the filename and URL for the stable release
 if [ "$OS" = "darwin" ]; then
   FILE="goose-$ARCH-apple-darwin.tar.bz2"
@aegntic aegntic force-pushed the fix/windows-cli-detection branch from 62d0099 to 364e222 Compare October 6, 2025 17:17
@aegntic aegntic force-pushed the fix/windows-cli-detection branch from 364e222 to 9b8cdf6 Compare October 6, 2025 17:34
@aegntic
Copy link
Contributor Author

aegntic commented Oct 6, 2025

sorted
:)

@DOsinga DOsinga mentioned this pull request Oct 6, 2025
9 tasks
@taniandjerry
Copy link
Contributor

Closed #5033 as dupe of this one!

@DOsinga DOsinga merged commit bb1d24d into block:main Oct 7, 2025
10 checks passed
lifeizhou-ap added a commit that referenced this pull request Oct 7, 2025
* main:
  use agent manager for subagent (#4828)
  fix: improve Windows OS detection in CLI installation script (#4928)
  Make it startable from playwright and also isolate (#5016)
  Fix linux deeplinks not working (#5041)
  docs: embed more videos (#5042)
  Display extension install notes in "Add custom extension" form (#5036)
  Add support for headers in extensions deeplinks (#5034)
  chore: put test in the name (#4919)
  Add new subcommand for opening recipes in desktop app (#4970)
  Update system.md with softer subagent language (#5023)
  docs: add new goose tip (#4941)
  Fix nix flake double copy (#4976)
  Upgrade electron for macOS Tahoe compatibility (#5015)
Itz-Agasta pushed a commit to Itz-Agasta/goose that referenced this pull request Oct 7, 2025
)

Signed-off-by: aegntic <[email protected]>
Co-authored-by: aegntic <[email protected]>

the test seemed stuck on the typescript tests, but this is an install script so skipping. could be bad

Signed-off-by: Itz-Agasta <[email protected]>
ARYPROGRAMMER pushed a commit to ARYPROGRAMMER/goose that referenced this pull request Oct 7, 2025
)

Signed-off-by: aegntic <[email protected]>
Co-authored-by: aegntic <[email protected]>

the test seemed stuck on the typescript tests, but this is an install script so skipping. could be bad

Signed-off-by: Arya Pratap Singh <[email protected]>
katzdave added a commit that referenced this pull request Oct 7, 2025
…aned-tool-calls

* 'main' of github.com:block/goose: (38 commits)
  docs: misc updates for extensions directory (#5035)
  updating recipe scanner workflows for detecting recipes from forked repos (#5056)
  feat(prompt-library): add Smart Meeting Assistant advanced prompt (#4998) (#5031)
  Allow auto focus and typing while chat is initializing (#5043)
  docs(blog): Add blog for running Goose in containerized envs  (#5052)
  fix: Add WINDOWS_CODESIGN_CERTIFICATE to nightly workflow (#5037)
  Developer `analyze` tool improvement (#5030)
  use agent manager for subagent (#4828)
  fix: improve Windows OS detection in CLI installation script (#4928)
  Make it startable from playwright and also isolate (#5016)
  Fix linux deeplinks not working (#5041)
  docs: embed more videos (#5042)
  Display extension install notes in "Add custom extension" form (#5036)
  Add support for headers in extensions deeplinks (#5034)
  chore: put test in the name (#4919)
  Add new subcommand for opening recipes in desktop app (#4970)
  Update system.md with softer subagent language (#5023)
  docs: add new goose tip (#4941)
  Fix nix flake double copy (#4976)
  Upgrade electron for macOS Tahoe compatibility (#5015)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI Installation on Windows fails because of missing bzip2 install

4 participants