Sirsemy
Sirsemy

Reputation: 157

Unsupported operating system Laravel 8 with Sail on Windows 10 (WSL2)

I've spent 13 hours to compose Laravel Sail and I hadn't able to install it on Windows 10 operating system. But later fortunately my collegaue found the solution when he also bumbed into this error message:

Unsupported operating system [MINGW64_NT-10.0-19042]. Laravel Sail supports macOS, Linux, and Windows (WSL2).

During the 13 hours:

The solution and partial explanations are in my answer.

Upvotes: 1

Views: 1615

Answers (1)

Sirsemy
Sirsemy

Reputation: 157

The solution is in Sail and the issue is a kind of bug.

But first the prepare steps:

  • You need install Docker Desktop on your Windos
  • You need install and set WSL 2 by this guide: https://learn.microsoft.com/en-us/windows/wsl/install but
  • You absolutely not need to install Linux on Windows. Because the problem is an operation system checking condition in Sail.
  • Find the sail file in the vendor folder: vendor/laravel/sail/bin/sail and change from this code:

     Verify operating system is supported...
    case "${UNAMEOUT}" in
        Linux*)             MACHINE=linux;;
        Darwin*)            MACHINE=mac;;
        *)                  MACHINE="UNKNOWN"
    esac
    
    if [ "$MACHINE" == "UNKNOWN" ]; then
        echo "Unsupported operating system [$(uname -s)]. Laravel Sail supports macOS, Linux, and Windows (WSL2)." >&2
    
        exit 1
    fi

to this:


    # Verify operating system is supported...
    #case "${UNAMEOUT}" in
    #    Linux*)             MACHINE=linux;;
    #    Darwin*)            MACHINE=mac;;
    #    *)                  MACHINE="UNKNOWN"
    #esac
    #
    #if [ "$MACHINE" == "UNKNOWN" ]; then
    #    echo "Unsupported operating system [$(uname -s)]. Laravel Sail supports macOS, Linux, and Windows (WSL2)." >&2
    #
    #    exit 1
    #fi

This solve the problem. And why can we do this? Because to check the vendor/laravel/sail/bin/sail bash file you can notice that every command can run in bash and terminal on Windows also without any problem. Maybe they forget to put a Windows checking line in this code segment above.

To do these process Laravel Sail works like a charm based on Laravel Sail documentation.

And don't forget that this is just a hotfix because the next Sail update will override the modified sail bash file!

Upvotes: 2

Related Questions