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

Laravel Sail未创建项目文件夹问题求助

问题

在Mac系统上,已安装Docker,尝试使用Laravel Sail搭建Laravel项目。执行命令:

curl -s https://laravel.build/devdojo-sail | bash

后,输出显示项目创建在/opt/devdojo-sail,但本地当前目录并未生成devdojo-sail文件夹,后续执行相关命令报错。完整执行输出如下:

latest: Pulling from laravelsail/php82-composer
Digest:
Status: Image is up to date for laravelsail/php82-composer:latest

_ _
| | | |
| | __ _ _ __ __ ___ | |
| | / | '__/ _ \ \ / / _ \ |
| |
| (| | | | (| |\ V / / |
|
_,|| _,| _/ ___|_|

WARN TTY mode requires /dev/tty to be read/writable.

Creating a "laravel/laravel" project at "./devdojo-sail"
Info from https://repo.packagist.org: #StandWithUkraine
Installing laravel/laravel (v10.2.6)
  - Downloading laravel/laravel (v10.2.6)
  - Installing laravel/laravel (v10.2.6): Extracting archive
Created project in /opt/devdojo-sail
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
...
<PACKAGES DOWNLOADED AND INSTALLED HERE>
...

INFO Discovering packages.

laravel/sail     ..........................................................     DONE

laravel/sanctum ....................................................... DONE
laravel/tinker ........................................................ DONE
nesbot/carbon ......................................................... DONE
nunomaduro/collision .................................................. DONE
nunomaduro/termwind ................................................... DONE
spatie/laravel-ignition ............................................... DONE

82 packages you are using are looking for funding.

Use the composer fund command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

INFO No publishable resources for tag [laravel-assets].

No security vulnerability advisories found
> @php artisan key:generate --ansi

INFO Application key set successfully.

INFO Application ready! Build something amazing.

Sail scaffolding installed successfully.
WARN TTY mode requires /dev/tty to be read/writable.

bash: line 17: cd: devdojo-sail: No such file or directory
bash: line 23: ./vendor/bin/sail: No such file or directory
bash: line 24: ./vendor/bin/sail: No such file or directory

解决方案

1. 问题根源

Laravel Sail初始化脚本会在Docker容器内部创建项目,若未指定本地挂载路径,项目默认生成在容器的/opt目录下,而非你的本地当前工作目录,因此本地找不到项目文件夹。

2. 重新创建项目到本地目录

方法一:指定路径生成

执行初始化命令时,通过--path参数明确将项目生成到本地当前目录:

curl -s https://laravel.build/devdojo-sail | bash -s -- --path ./

方法二:进入目标目录后创建

先在本地创建并进入目标文件夹:

mkdir devdojo-sail && cd devdojo-sail

再执行不带项目名的初始化命令:

curl -s https://laravel.build | bash

3. 迁移已创建的项目

若不想重新创建,可将容器内的项目复制到本地:

  1. 查找运行过的Laravel Sail容器ID:
docker ps -a
  1. 使用docker cp命令将容器内的项目复制到本地指定路径(替换<container_id>和/本地目标路径为实际值):
docker cp <container_id>:/opt/devdojo-sail /本地目标路径

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 16:35:01