You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel Sail执行./vendor/bin/sail up启动失败求助

问题描述

按照以下步骤安装全新Laravel项目后,执行./vendor/bin/sail up无法启动:

curl -s "https://laravel.build/example-app" | bash

cd example-app
 
./vendor/bin/sail up

系统环境

  • MacBook Air
  • Apple M2芯片
  • macOS: Ventura 13.4.1 (22F82)
  • Windows环境下也出现相同问题,新旧项目均受影响

Docker情况

已完全卸载并重新安装过Docker

报错信息

#0 196.1 ## Running `apt-get update` for you...
#0 196.1 
#0 196.1 + apt-get update
#0 196.2 Get:1 https://deb.nodesource.com/node_18.x jammy InRelease [4563 B]
#0 196.3 Get:2 https://deb.nodesource.com/node_18.x jammy/main arm64 Packages [776 B]
#0 196.3 Err:2 https://deb.nodesource.com/node_18.x jammy/main arm64 Packages
#0 196.3   File has unexpected size (778 != 776). Mirror sync in progress? [IP: 23.34.82.11 443]
#0 196.3   Hashes of expected file:
#0 196.3    - Filesize:776 [weak]
#0 196.3    - SHA256:4cdc71073957aaffbea511d99669cc4fa98b752eab966068a023558555e0ab92
#0 196.3    - SHA1:0b9c08bd020fac9bc1d05b3008fe7aeee3d1a182 [weak]
#0 196.3    - MD5Sum:fc5eace817a48e2a439589628112ec00 [weak]
#0 196.3   Release file created at: Thu, 13 Apr 2023 14:12:05 +0000
#0 196.3 Hit:3 http://ports.ubuntu.com/ubuntu-ports jammy InRelease
#0 196.4 Hit:4 http://ports.ubuntu.com/ubuntu-ports jammy-updates InRelease
#0 196.5 Hit:5 http://ports.ubuntu.com/ubuntu-ports jammy-backports InRelease
#0 196.5 Hit:6 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease
#0 196.6 Hit:7 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease
#0 196.7 Fetched 4563 B in 1s (7785 B/s)
#0 196.7 Reading package lists...
#0 197.1 E: Failed to fetch https://deb.nodesource.com/node_18.x/dists/jammy/main/binary-arm64/Packages.gz  File has unexpected size (778 != 776). Mirror sync in progress? [IP: 23.34.82.11 443]
#0 197.1    Hashes of expected file:
#0 197.1     - Filesize:776 [weak]
#0 197.1     - SHA256:4cdc71073957aaffbea511d99669cc4fa98b752eab966068a023558555e0ab92
#0 197.1     - SHA1:0b9c08bd020fac9bc1d05b3008fe7aeee3d1a182 [weak]
#0 197.1     - MD5Sum:fc5eace817a48e2a439589628112ec00 [weak]
#0 197.1    Release file created at: Thu, 13 Apr 2023 14:12:05 +0000
#0 197.1 E: Some index files failed to download. They have been ignored, or old ones used instead.
#0 197.1 Error executing command, exiting
------
failed to solve: process "/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 dnsutils librsvg2-bin     && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null     && echo \"deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main\" > /etc/apt/sources.list.d/ppa_ondrej_php.list     && apt-get update     && apt-get install -y php8.2-cli php8.2-dev        php8.2-pgsql php8.2-sqlite3 php8.2-gd php8.2-imagick        php8.2-curl        php8.2-imap php8.2-mysql php8.2-mbstring        php8.2-xml php8.2-zip php8.2-bcmath php8.2-soap        php8.2-intl php8.2-readline        php8.2-ldap        php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole        php8.2-memcached php8.2-pcov php8.2-xdebug     && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer     && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash -     && apt-get install -y nodejs     && npm install -g npm     && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null     && echo \"deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main\" > /etc/apt/sources.list.d/yarn.list     && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null     && echo \"deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main\" > /etc/apt/sources.list.d/pgdg.list     && apt-get update     && apt-get install -y yarn     && apt-get install -y mysql-client     && apt-get install -y postgresql-client-$POSTGRES_VERSION     && apt-get -y autoremove     && apt-get clean     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*\" did not complete successfully: exit code: 1
解决方案

方法1:清理Docker缓存后重新构建

清理本地缓存的镜像和容器,避免旧的索引文件干扰:

# 停止所有运行的容器
docker stop $(docker ps -aq)
# 删除所有未使用的镜像、容器、卷和网络
docker system prune -af
# 进入项目目录重新构建并启动
cd example-app
./vendor/bin/sail build --no-cache
./vendor/bin/sail up

方法2:替换Node源或跳过Node安装

选项A:替换Node源为国内镜像

如果NodeSource源同步异常,可替换为国内镜像:

  1. 在项目根目录创建自定义Dockerfile目录:
mkdir -p docker/8.2
  1. 创建docker/8.2/Dockerfile文件,内容如下:
FROM laravel/sail:8.2

# 替换NodeSource源为国内镜像
RUN rm /etc/apt/sources.list.d/nodesource.list && \
    curl -sLS https://deb.nodesource.com/setup_18.x | bash - && \
    sed -i 's|deb.nodesource.com|mirrors.aliyun.com/nodesource/deb|g' /etc/apt/sources.list.d/nodesource.list && \
    apt-get update && apt-get install -y nodejs
  1. 修改项目根目录的docker-compose.yml,指定自定义构建路径:
services:
    laravel.test:
        build:
            context: ./docker/8.2
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
  1. 重新构建启动:
./vendor/bin/sail build --no-cache
./vendor/bin/sail up

选项B:跳过Node和Yarn安装(仅后端开发)

如果不需要前端工具,可直接跳过相关安装步骤:

  1. 创建docker/8.2/Dockerfile文件:
FROM laravel/sail:8.2

# 仅保留后端所需依赖
RUN apt-get update && apt-get install -y mysql-client postgresql-client-14 && \
    apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  1. 修改docker-compose.yml的build配置同上,再重新构建启动。

方法3:等待镜像同步完成

报错提示"Mirror sync in progress",说明NodeSource服务器正在同步镜像,等待10-30分钟后直接执行以下命令重试:

cd example-app
./vendor/bin/sail up

内容的提问来源于stack exchange,提问作者Dino Cajic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 18:42:06