Laravel Sail 環境下啟動專案出現: ERROR: Service 'laravel.test' failed to build

Alcohol 發表於 2021-05-03

本文發表於2021年5月3日(假期學習爽翻天,二話不說瘋狂卷)
錯誤截圖如下:
Laravel Sail 環境下啟動專案出現: ERROR: Service 'laravel.test' failed to build
關鍵字眼:

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 協議》,轉載必須註明作者和本文連結