sail: Laravel Sail fails to build laravel.test service

  • Sail Version: 1.8.2
  • Laravel Version: 8.48.2
  • PHP Version: 8.0.6
  • OS: Windows running WSL2 Ubuntu 20.04

Description:

sail up fails building laravel.test service by this error:

Building laravel.test
[+] Building 217.8s (9/16)                                                                                                                                                                                                          
 => [internal] load build definition from Dockerfile                                                                                                                                                                           0.0s
 => => transferring dockerfile: 2.43kB                                                                                                                                                                                         0.0s
 => [internal] load .dockerignore                                                                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/ubuntu:21.04                                                                                                                                                                3.4s
 => [internal] load build context                                                                                                                                                                                              0.0s
 => => transferring context: 906B                                                                                                                                                                                              0.0s
 => [ 1/12] FROM docker.io/library/ubuntu:21.04@sha256:a30456233740024b9d297f5bcaa7439446a97bc59b25cadcdae829c334827945                                                                                                        3.8s
 => => resolve docker.io/library/ubuntu:21.04@sha256:a30456233740024b9d297f5bcaa7439446a97bc59b25cadcdae829c334827945                                                                                                          0.0s
 => => sha256:3e2d1c03542857d58a3cae774cad57f863543c683f444da46126220e343c359f 31.84MB / 31.84MB                                                                                                                               1.6s
 => => sha256:a30456233740024b9d297f5bcaa7439446a97bc59b25cadcdae829c334827945 1.20kB / 1.20kB                                                                                                                                 0.0s
 => => sha256:13dc7df85a3315882644746ae501acdbf40e96d2f4c1df0032cc18f10a2e0c50 529B / 529B                                                                                                                                     0.0s
 => => sha256:093da574621da4e7c9f9560f7a929e3e8e26de6a15096630ec874669a5f89427 1.46kB / 1.46kB                                                                                                                                 0.0s
 => => extracting sha256:3e2d1c03542857d58a3cae774cad57f863543c683f444da46126220e343c359f                                                                                                                                      2.0s
 => [ 2/12] WORKDIR /var/www/html                                                                                                                                                                                              0.1s
 => [ 3/12] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone                                                                                                                                     0.3s
 => [ 4/12] 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 "di  209.3s
 => ERROR [ 5/12] RUN pecl channel-update https://pecl.php.net/channel.xml     && pecl install swoole     && pecl clear-cache     && rm -rf /tmp/* /var/tmp/*                                                                  0.5s
------
 > [ 5/12] RUN pecl channel-update https://pecl.php.net/channel.xml     && pecl install swoole     && pecl clear-cache     && rm -rf /tmp/* /var/tmp/*:
#8 0.465 PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Config.php on line 2095
------
executor failed running [/bin/sh -c pecl channel-update https://pecl.php.net/channel.xml     && pecl install swoole     && pecl clear-cache     && rm -rf /tmp/* /var/tmp/*]: exit code: 255
ERROR: Service 'laravel.test' failed to build : Build failed

Steps To Reproduce:

After installing Sail on the project and adding mariadb through php artisan sail:install you do sail up (with proper alias pointing to vendor/bin/sail)

Then docker starts building all docker-compose.yml services and stops because this line:

#8 0.465 PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Config.php on line 2095

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 29 (6 by maintainers)

Most upvoted comments

Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal

Steps:

  1. Run ‘composer install’
  2. Run ‘./vendor/bin/sail build’

Error:

[...]
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php8.0/php8.0-mysql_8.0.12-1%2bubuntu21.04.1%2bdeb.sury.org%2b1_amd64.deb  Connection timed out [IP: 91.189.95.85 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
ERROR: Service 'laravel.test' failed to build: The command '/bin/sh -c 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 hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php8.0-cli php8.0-dev        php8.0-pgsql php8.0-sqlite3 php8.0-gd        php8.0-curl php8.0-memcached        php8.0-imap php8.0-mysql php8.0-mbstring        php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap        php8.0-intl php8.0-readline php8.0-pcov        php8.0-msgpack php8.0-igbinary php8.0-ldap        php8.0-redis php8.0-swoole php8.0-xdebug     && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer     && curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -     && apt-get install -y nodejs     && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -     && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*' returned a non-zero code: 100

Solution:

  1. Run ‘composer update’
  2. You should have now ‘8.1’ dicrectory in ‘vendor/laravel/sail/runtimes’
  3. Change ‘context: ./vendor/laravel/sail/runtimes/8.0’ to ‘context: ./vendor/laravel/sail/runtimes/8.1’ in docker-compose.yml
  4. Run ‘./vendor/bin/sail build’
  5. Run ‘./vendor/bin/sail up -d’

This a Pear/PECL problem. The PEAR library included with the Ubuntu distribution is very old. To fix it, make sure you have the latest version.

Add this to the Dockerfile after the PHP block:

    && wget http://pear.php.net/go-pear.phar \
    && php go-pear.phar \
    && pecl channel-update pecl.php.net \

Just installed WSL2 and Docker, tried to create a new laravel sail project and got the same error. Don’t think it’s a problem with Docker containers/volumes because I did a clean install and still got the error

Run this: docker system prune --force. It will probably free up GBs of disk space.

Then make sure that you are installing the php-xml extension as well as the php8.0-xml extension whilst you’re at it.

It solved my build issues after Sail upgraded as part of the Laravel 9 upgrade.

Run this: docker system prune --force. It will probably free up GBs of disk space.

Then make sure that you are installing the php-xml extension as well as the php8.0-xml extension whilst you’re at it.

It solved my build issues after Sail upgraded as part of the Laravel 9 upgrade.

Thanks! System prune helped!

Hi, I’ve been having a lot of problems with Laravel sail to run up my Laravel projects, some times I’d uninstall docker completely and reinstall it newly, but now I’ve removed the composer.lock and did run composer update after that I’d run sail up -d and I resolved.

I experienced this exact same issue on MacOS with 1.8.2, downgraded to 1.8.1 and containers built with no issues.