1

我在使用 PHP 8.0 的 Sail 中使用 Laravel 8.x,最近,我实际上弄乱了我的 compose.json 文件,导致供应商出现问题,试图从头开始重新创建项目,我删除了供应商文件夹。

通常,docker-compose 会构建并创建/path/to/project/vendor/laravel/sail/runtimes/具有适当内容的目录,但由于某种原因,我不断收到以下错误:

ERROR: build path /path/to/project/vendor/laravel/sail/runtimes/8.0 either does not exist, is not accessible, or is not a valid URL.

我尝试docker system prune通过 Docker Desktop 界面手动使用和删除现有容器,甚至尝试使用 运行它docker-compose build --no-cache,但仍然遇到相同的错误。

有没有办法解决这个问题,或者我应该再次克隆我的项目并尝试构建它?

注意:我使用的是旧 Mac,无法手动运行composer install,因此我与实例的任何交互都依赖于 docker 容器的工作。

4

2 回答 2

1
docker run --rm --interactive --tty --volume C:/path/to/project:/app composer install --ignore-platform-reqs --no-scripts
于 2022-01-22T12:20:57.030 回答
0

The standard procedure for setting up any Laravel project should be running composer install, so an inability to do so really ties one's hands here.

However, in this case, where the only way for me to run composer was through docker, I elected to use the laravel.build website to create a new project and copy the vendor folder over. Here's the script:

docker info > /dev/null 2>&1

# Ensure that Docker is running...
if [ $? -ne 0 ]; then
    echo "Docker is not running."

    exit 1
fi

docker run --rm \
    -v $(pwd):/opt \
    -w /opt \
    laravelsail/php80-composer:latest \
    bash -c "laravel new example-app && cd example-app && php ./artisan sail:install --with=mysql,redis,meilisearch,mailhog,selenium"

cd example-app

CYAN='\033[0;36m'
LIGHT_CYAN='\033[1;36m'
WHITE='\033[1;37m'
NC='\033[0m'

echo ""

if sudo -n true 2>/dev/null; then
    sudo chown -R $USER: .
    echo -e "${WHITE}Get started with:${NC} cd example-app && ./vendor/bin/sail up"
else
    echo -e "${WHITE}Please provide your password so we can make some final adjustments to your application's permissions.${NC}"
    echo ""
    sudo chown -R $USER: .
    echo ""
    echo -e "${WHITE}Thank you! We hope you build something incredible. Dive in with:${NC} cd example-app && ./vendor/bin/sail up"
fi

After that, running ./vendor/bin/sail up -d && ./vendor/bin/sail composer install fixed the problem.

于 2021-06-20T12:28:13.490 回答