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

本文发表于2021年5月3日(假期学习爽翻天,二话不说疯狂卷)
错误截图如下:
Image
关键字眼:

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 项目,愉快地开始学习。

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

参考资料
1.
ubuntu中,出现Failed to fetch http://…..时,需要换源
2.
搭建 Laravel Sail 的教程:定义镜像源部分内容

本作品采用《CC 协议》,转载必须注明作者和本文链接
Image
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 9

我换了中科大的大好像还是不行。。跟WiFi有关系吗

4年前 评论
Image Alcohol (楼主) 4年前
Image Katrigeng (作者) 4年前
Image Katrigeng (作者) 4年前
Image Alcohol (楼主) 4年前

中科大的镜像我试了一下可以用,谢谢!

4年前 评论

确实解决了,我这里阿里云镜像试了一个星期一直失败,换中科大镜像就好了。

4年前 评论
Image Alcohol (楼主) 4年前

中科大的可以,成功了,谢谢

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!