Why is the "sail up" command not building my laravel docker containers?
Asked Answered
S

7

12

I'm trying out Laravel Sail, as I've been successfully using Laradock for a few years and hoping to simplify my dev environment setup. I am on Windows 10 64, Docker Desktop 3.0 installed using WSL 2, and my Laravel app is running Laravel 8.20.1.

In my Laravel project, I've followed the Laravel Sail setup guide: I've run composer require laravel/sail --dev and php artisan sail:install, and I see the docker-compose.yml in my root directory.

But when I run ./vendor/bin/sail up I get this error:

./vendor/bin/sail: line 1: XSym: command not found
./vendor/bin/sail: line 2: 0024: command not found
./vendor/bin/sail: line 3: a81960381c7144e16cd1e768af147de3: command not found
./vendor/bin/sail: line 4: ../laravel/sail/bin/sail: No such file or directory

Update: I fixed the above through Qumber's help: removing /vendor/ and reinstalling. But now I get this error:

In GitBash I get this response:

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

If I try from Powershell now, I get:

/bin/bash: C:\Users\ssund\Source\steepdb\vendor\bin\/../laravel/sail/bin/sail: No such file or directory

-------------Requested attachments--------------------

docker-compose.yml:

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
            # - selenium
    # selenium:
    #     image: 'selenium/standalone-chrome'
    #     volumes:
    #         - '/dev/shm:/dev/shm'
    #     networks:
    #         - sail
    mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
    # memcached:
    #     image: 'memcached:alpine'
    #     ports:
    #         - '11211:11211'
    #     networks:
    #         - sail
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - 1025:1025
            - 8025:8025
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local

Dockerfile in \vendor\laravel\sail\runtimes\7.4:

FROM ubuntu:20.04

LABEL maintainer="Taylor Otwell"

ARG WWWGROUP

WORKDIR /var/www/html

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update \
    && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
    && mkdir -p ~/.gnupg \
    && chmod 600 ~/.gnupg \
    && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
    && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
    && apt-get update \
    && apt-get install -y php7.4-cli php7.4-dev \
       php7.4-pgsql php7.4-sqlite3 php7.4-gd \
       php7.4-curl php7.4-memcached \
       php7.4-imap php7.4-mysql php7.4-mbstring \
       php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap \
       php7.4-intl php7.4-readline php7.4-pcov \
       php7.4-msgpack php7.4-igbinary php7.4-ldap \
       php7.4-redis \
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && curl -sL https://deb.nodesource.com/setup_15.x | bash - \
    && apt-get install -y nodejs \
    && apt-get install -y mysql-client \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN setcap "cap_net_bind_service=+ep" /usr/bin/php7.4

RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail

COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/7.4/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container

EXPOSE 8000

ENTRYPOINT ["start-container"]
Sympathy answered 24/12, 2020 at 18:5 Comment(7)
Try deleting your vendor directory and running composer update.Sox
Thank you @Qumber. I tried that and it got me a step further. I don't have the 4 errors. Now, when I run "./vendor/bin/sail up" from PowerShell I get a "How do you want to open this file" prompt. Forgive my ignorance, but I'm not sure what is actually supposed to run this. I have PHP 7.4 CLI and Docker Desktop 3 running, in case that matters.Sympathy
Could you share Dockerfile and docker-compose with us? Also, could you try the same in an Ubuntu terminal and if anything goes differently?Sox
@Sox I've attached the files for you above.Sympathy
Ok, I solved the issue in my second comment above by wiping vendor/ again and rerunning composer install. Now I'm getting "Unsupported operating system" when running from GitBash, and a file not found error when running from Powershell. I've added those full errors to the main question above.Sympathy
Have you tried running ./vendor/bin/sail up from WSL2 ?Quintuplet
@ClémentBaconnier thank you I just noticed your comment.after writing up my answer below. That was a big part of this.Sympathy
S
28

Ok there were multiple things that I needed to fix here.

  1. @Qumber helped me initially by suggesting I wipe /vendor/ and run composer install/update again. That fixed the missing sail file that wasn't getting added for some reason.
  2. I also had some permission-related issues, possibly due to running compose in WSL and then trying to run sail in Windows/GitBash (or vice versa).
  3. The biggest issue was my misunderstanding about Docker WSL2 integration and that the sail command should be run from within WLS (coming from Laradock, I made some incorrect assumptions). I needed to have a linux distro installed (I chose Ubuntu 20.x) AND make sure it was set as the default, via running wsl -s . You can check which is currently default with wsl -l -v. For more detailed steps about this setup see https://learn.microsoft.com/en-us/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package.

Once I fixed the above, I was able to open Windows Terminal, create an Ubuntu tab, and run ./vendor/bin/sail up and it executed.

Sympathy answered 30/12, 2020 at 21:6 Comment(4)
I have found that running from Windows Terminal gives very different (and much better) results than running WSL from a PowerShell. The former seems to set up all the correct permissions, while the latter does not. I think it relates to how the different terminals mount the filesystems between Windows and the host Linux OS, but there is some underlying differences that I've not been able to get to the bottom of. Windows Terminal is the way to go, in my experience.Margaretmargareta
Thanks. Changing the default distro to Debian (or Ubuntu) did it for meDiligent
Thanks. I was running the commands on Windows Terminal and receiving the message "No such file or directory". After running them in WSL2 terminal everything worked correctly.Mortgage
This solution is correct until this time being I change the permission of vendor, then followed the solution of Qumbor and sersun. I agree about this solution.Superable
T
2

If you're like me who cloned a Laravel project from GitHub where none of the application's Composer dependencies are available including Sail, you'll need to run the following commands from the project directory. The following commands use a small Docker Container containing PHP and Composer to install the application's dependencies:

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

Further information can be found on the Laravel documentation.

Toluidine answered 31/7, 2021 at 8:31 Comment(0)
Z
1

You need to install linux under windows first. Your answer is correct. Thanks :)

Zacarias answered 16/1, 2021 at 15:59 Comment(0)
B
0

For me, this was a permissions issue. Running as sudo worked.

Using Win10 with WSL Ubuntu 20.04 LTS.

Blepharitis answered 26/3, 2021 at 19:59 Comment(0)
R
0

I was facing this problem on my Mac .This issue is due to permission

Solution for MAC

1: Pull down the  Apple menu and choose ‘System Preferences’

2: Choose “Security & Privacy” control panel

3: Now select the “Privacy” tab, then from the left-side menu select “Full Disk Access”

4:Click the lock icon in the lower left corner of the preference panel and authenticate with an admin level login

5: Now click the [+] plus button to add an application with full disk access

6:Navigate to the /Applications/Utilities/ folder and choose “Terminal” to grant Terminal with Full Disk Access privileges

7: Relaunch Terminal, the “Operation not permitted” error messages will be gone

After that you can install Laravel.

Rustproof answered 9/6, 2022 at 7:22 Comment(0)
G
0

Solution for Windows 10 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

then use GitBash to run commond

./vendor/bin/sail up

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

Gilbertogilbertson answered 8/11, 2022 at 13:32 Comment(0)
A
-5

This may sound crazy, but I had the same issue.

I just did vendor/bin/sail up

Instead of .vendor/bin/sail up

And that worked!

Archetype answered 12/8, 2021 at 4:28 Comment(1)
This was solution in my case. Stop downvoting working solutions and grow up.Marketa

© 2022 - 2025 — McMap. All rights reserved.