Laravel Sail 环境下启动项目出现: ERROR: Service 'laravel.test' failed to build

Laravel框架
449
0
0
2022-04-11

本文发表于2021年5月3日(假期学习爽翻天,二话不说疯狂卷)

错误截图如下:

关键字眼:

failed to fetch http://......

搜索得出结论:镜像源的问题,要更换镜像源

之前在搭建环境的时候,已经对 Laravel Sail 的镜像源定制过,所以更换起来很简单。

之前定义镜像源地址的文件是:

vendor/laravel/sail/runtimes/8.0/sources.list

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

可以看出用的是阿里云的镜像源,我先是更换为清华大学的镜像源,结果失败。

第二次更换为中科大的镜像源,然后成功启动 Laravel 项目。

更换后的文件如下:

deb http://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

具体做法:先将vendor/laravel/sail/runtimes/8.0/sources.list文件的内容清空,在将以上代码复制粘贴保存即可。

亲测成功启动 Laravel 项目,愉快地开始学习。

别看这个动作很简单,倒腾来倒腾去,也花了将近两小时,我什么时候才能转行成功啊。