Homestead.test报"No input file specified"及vagrant provision报错
Laravel Homestead 环境故障修复
故障背景
- 本周一存在重要项目截止节点,需要快速恢复环境正常运行
- 已尝试的常规重启/重配/重建操作均未解决问题
- 一个月前可正常访问的
homestead.test站点当前无法连通 - 曾遇到过完全一致的故障,但未留存当时的解决步骤
已尝试操作
- 执行
vagrant halt关闭虚拟机后重新启动 - 执行
vagrant up --provision触发强制重新配置 - 执行
vagrant destroy彻底销毁虚拟机实例后重新初始化
Provision 流程输出日志
Bringing machine 'homestead' up with 'virtualbox' provider... ==> homestead: Checking if box 'laravel/homestead' version '9.7.2' is up to date... ==> homestead: Running provisioner: file... homestead: /Users/benpoarch/LaravelStuff/Homestead/aliases => /tmp/bash_aliases ==> homestead: Running provisioner: shell... homestead: Running: inline script ==> homestead: Running provisioner: shell... homestead: Running: inline script homestead: Unable to mount one of your folders. Please check your folders in Homestead.yaml ==> homestead: Running provisioner: shell... homestead: Running: inline script ==> homestead: Running provisioner: shell... homestead: Running: inline script ==> homestead: Running provisioner: shell... homestead: Running: inline script homestead: Ignoring feature: mysql because it is set to false ==> homestead: Running provisioner: shell... homestead: Running: inline script homestead: Ignoring feature: mariadb because it is set to false ==> homestead: Running provisioner: shell... homestead: Running: inline script homestead: Ignoring feature: ohmyzsh because it is set to false ==> homestead: Running provisioner: shell... homestead: Running: inline script homestead: Ignoring feature: webdriver because it is set to false ==> homestead: Running provisioner: shell... homestead: Running: /var/folders/xj/vfzltd1s4jbf1w8r7_8n6b_h0000gn/T/vagrant-shell20210102-10417-1qoqqjs.sh ==> homestead: Running provisioner: shell... homestead: Running: /var/folders/xj/vfzltd1s4jbf1w8r7_8n6b_h0000gn/T/vagrant-shell20210102-10417-1ykt8te.sh ==> homestead: Running provisioner: Creating Certificate: homestead.test (shell)... homestead: Running: script: Creating Certificate: homestead.test ==> homestead: Running provisioner: Creating Site: homestead.test (shell)... homestead: Running: script: Creating Site: homestead.test ==> homestead: Running provisioner: shell... homestead: Running: inline script ==> homestead: Running provisioner: shell... homestead: Running: /var/folders/xj/vfzltd1s4jbf1w8r7_8n6b_h0000gn/T/vagrant-shell20210102-10417-dh5zkp.sh ==> homestead: Running provisioner: Checking for old Schedule (shell)... homestead: Running: script: Checking for old Schedule ==> homestead: Running provisioner: Creating Certificate: homestead2.test (shell)... homestead: Running: script: Creating Certificate: homestead2.test ==> homestead: Running provisioner: Creating Site: homestead2.test (shell)... homestead: Running: script: Creating Site: homestead2.test ==> homestead: Running provisioner: shell... homestead: Running: inline script ==> homestead: Running provisioner: shell... homestead: Running: /var/folders/xj/vfzltd1s4jbf1w8r7_8n6b_h0000gn/T/vagrant-shell20210102-10417-725eap.sh ==> homestead: Running provisioner: Checking for old Schedule (shell)... homestead: Running: script: Checking for old Schedule ==> homestead: Running provisioner: Clear Variables (shell)... homestead: Running: script: Clear Variables ==> homestead: Running provisioner: Restarting Cron (shell)... homestead: Running: script: Restarting Cron ==> homestead: Running provisioner: Restart Webserver (shell)... homestead: Running: script: Restart Webserver ==> homestead: Running provisioner: Update Composer (shell)... homestead: Running: script: Update Composer homestead: You are already using composer version 2.0.8 (stable channel). homestead: chown: cannot access '/home/vagrant/.composer/': No such file or directory The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.
关键异常定位
从日志中可提取两个核心阻断点,任意一个未解决都会导致provision流程中断、环境无法正常运行:
- 虚拟主机存在挂载失败的共享目录,直接对应
Homestead.yaml的目录映射配置问题 - 虚拟机内部缺失
/home/vagrant/.composer目录,导致最后一步权限修正命令执行失败
修复操作步骤
按照优先级从快到慢执行:
- 排查共享目录挂载问题
- 逐行核对
Homestead.yaml中所有folders配置的本地路径,确认路径无拼写错误、对应目录真实存在 - macOS 环境下检查系统权限:打开「系统设置-隐私与安全性-完全磁盘访问权限」,确认终端、VirtualBox 均已获得权限,避免因系统权限拦截导致目录挂载失败
- 快速定位故障目录:临时注释所有映射配置,仅保留核心代码目录的映射关系,重新执行
vagrant up --provision,确认无挂载报错后再逐步恢复其他映射,标记出挂载失败的具体路径
- 逐行核对
- 修复 Composer 目录缺失问题
- 执行
vagrant ssh进入虚拟机内部 - 手动创建缺失目录并修正权限:
mkdir -p /home/vagrant/.composer chown -R vagrant:vagrant /home/vagrant/.composer - 退出SSH会话,重新执行
vagrant provision验证流程是否能完整走完
- 执行
- 连通性验证
- 检查本地
hosts文件中homestead.test的IP指向,确认和Homestead.yaml中配置的虚拟机IP一致 - 进入虚拟机内部重启Web服务:
sudo service nginx restart - 浏览器访问
homestead.test确认页面可正常加载
- 检查本地
内容的提问来源于stack exchange,提问作者bpoarch
相关产品推荐
相关产品推荐

