Skip to content

Instantly share code, notes, and snippets.

@JoshSalway
Created March 18, 2026 05:33
Show Gist options
  • Select an option

  • Save JoshSalway/bcb643e555ecf66d0306bb704c7ace87 to your computer and use it in GitHub Desktop.

Select an option

Save JoshSalway/bcb643e555ecf66d0306bb704c7ace87 to your computer and use it in GitHub Desktop.
Fix for laravel/sail #850 - Windows non-WSL shell detection
From bdecf7ff68d316f90a289d0c63b7cebe349c2f63 Mon Sep 17 00:00:00 2001
From: Josh Salway <josh.salway@gmail.com>
Date: Wed, 18 Mar 2026 15:23:29 +1000
Subject: [PATCH] Detect Windows non-WSL shells and guide users to WSL
When running Sail from Git Bash (MINGW64), MSYS2, or Cygwin on
Windows, the sail script now provides a clear error message directing
users to run from within WSL2 instead of the generic "Unsupported
operating system" error.
Additionally, `prepareInstallation()` now detects when PHP is running
on Windows natively and skips the Unix-only shell commands (which
would fail with "The system cannot find the path specified"), showing
a warning to complete setup from WSL instead.
Fixes #850
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---
bin/sail | 9 +++++++++
.../Concerns/InteractsWithDockerComposeServices.php | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/bin/sail b/bin/sail
index 0f75362..e951426 100755
--- a/bin/sail
+++ b/bin/sail
@@ -6,6 +6,15 @@ UNAMEOUT="$(uname -s)"
case "${UNAMEOUT}" in
Linux*) MACHINE=linux;;
Darwin*) MACHINE=mac;;
+ MINGW*|MSYS*|CYGWIN*)
+ echo "Sail must be run from within WSL2, not from ${UNAMEOUT}." >&2
+ echo "" >&2
+ echo "Please open a WSL terminal and run Sail from there:" >&2
+ echo " wsl" >&2
+ echo " cd /mnt/c/path/to/your/project" >&2
+ echo " ./vendor/bin/sail up" >&2
+
+ exit 1;;
*) MACHINE="UNKNOWN"
esac
diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php
index 6a08e14..770f530 100644
--- a/src/Console/Concerns/InteractsWithDockerComposeServices.php
+++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php
@@ -290,6 +290,13 @@ trait InteractsWithDockerComposeServices
*/
protected function prepareInstallation($services)
{
+ // Skip pulling and building on Windows as the sail script requires WSL...
+ if ('\\' === DIRECTORY_SEPARATOR) {
+ $this->components->warn('Please run [./vendor/bin/sail up] from within WSL to complete the installation.');
+
+ return;
+ }
+
// Ensure docker is installed...
if ($this->runCommands(['docker info > /dev/null 2>&1']) !== 0) {
return;
--
2.53.0.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment