【问题标题】:Unsupported operating system Laravel 8 with Sail on Windows 10 (WSL2)Windows 10 (WSL2) 上不支持的操作系统 Laravel 8 with Sail
【发布时间】:2021-12-20 21:29:57
【问题描述】:

我花了 13 个小时编写 Laravel Sail,但我无法在 Windows 10 操作系统上安装它。 但幸运的是,后来我的同事在遇到此错误消息时也找到了解决方案:

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

在 13 小时内:

解决方案和部分解释在我的回答中。

【问题讨论】:

    标签: linux docker windows-10 wsl-2 laravel-sail


    【解决方案1】:

    解决方案在 Sail 中,问题是一种错误。

    但首先是准备步骤:

    • 您需要在 Windows 上安装 Docker Desktop
    • 您需要按照本指南安装和设置 WSL 2:https://docs.microsoft.com/en-us/windows/wsl/install 但是
    • 您绝对不需要在 Windows 上安装 Linux。因为问题是 Sail 中的操作系统检查条件。
    • 在供应商文件夹中找到sail 文件:vendor/laravel/sail/bin/sail 并从此代码更改:
    
         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
    
    

    到这里:

    
        # 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
    
    

    这解决了问题。 为什么我们可以这样做? 因为要检查vendor/laravel/sail/bin/sail bash 文件,您会注意到每个命令都可以在Windows 上的bash 和终端中运行,也没有任何问题。 也许他们忘记在上面的这段代码中添加一个 Windows 检查行。

    要完成这些过程,Laravel Sail 就像基于 Laravel Sail 文档的魅力一样工作。

    别忘了这只是一个修补程序,因为下一次 Sail 更新将覆盖修改后的 Sail bash 文件!

    【讨论】:

      猜你喜欢
      • 2021-05-30
      • 1970-01-01
      • 1970-01-01
      • 2015-10-25
      • 2019-10-18
      • 2021-05-05
      • 2016-03-15
      • 2018-03-20
      • 1970-01-01
      相关资源
      最近更新 更多