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

Laravel Homestead执行vagrant up报错:版本约束不匹配

Vagrant启动Homestead版本约束错误处理

对应的Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "laravel/homestead"

  if File.exist? aliasesPath
    config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
    config.vm.provision "handle_aliases", type: "shell" do |s|
      s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases"
    end
  end

  if File.exist? homesteadYamlPath
    settings = YAML::load(File.read(homesteadYamlPath))
  elsif File.exist? homesteadJsonPath
    settings = JSON::parse(File.read(homesteadJsonPath))
  else
    abort "Homestead settings file not found in #{confDir}"
  end

  Homestead.configure(config, settings)

  if File.exist? afterScriptPath
    config.vm.provision "Run after.sh", type: "shell", path: afterScriptPath, privileged: false, keep_color: true
  end

  if File.exist? customizationScriptPath
    config.vm.provision "Run customize script", type: "shell", path: customizationScriptPath, privileged: false, keep_color: true
  end

  if Vagrant.has_plugin?('vagrant-hostsupdater')
    config.hostsupdater.remove_on_suspend = false
    config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
  elsif Vagrant.has_plugin?('vagrant-hostmanager')
    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
    config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
  elsif Vagrant.has_plugin?('vagrant-goodhosts')
    config.goodhosts.aliases = settings['sites'].map { |site| site['map'] }
  end

  if Vagrant.has_plugin?('vagrant-notify-forwarder')
    config.notify_forwarder.enable = true
  end
end

启动错误信息

在Homestead目录执行vagrant up时出现以下错误:

Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Box 'laravel/homestead' could not be found. Attempting to find and install...
homestead: Box Provider: virtualbox
homestead: Box Version: >= 13.0.0, < 14.0.0
==> homestead: Loading metadata for box 'laravel/homestead'
您尝试添加的盒子没有符合请求约束的可用版本,请仔细检查您的设置。同时请确认,如果您指定了版本约束,您想要使用的provider是否在这些约束下可用。

盒子:laravel/homestead
约束:>= 13.0.0, < 14.0.0
可用版本:0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.4, 0.2.5, 0.2.6, 0.2.7, 0.3.0, 0.3.3, 0.4.0, 0.4.1, 0.4.2, 0.4.4, 0.5.0, 0.6.0, 0.6.1, 1.0.0, 1.0.1, 1.1.0, 2.0.0, 2.1.0, 2.2.0, 3.0.0, 3.1.0, 4.0.0, 5.0.1, 5.1.0, 5.2.0, 6.0.0, 6.1.0, 6.2.0, 6.3.0, 6.4.0, 7.0.0, 7.1.0, 7.2.1, 8.0.0.pre.alpha1, 8.0.0.pre.alpha2, 8.0.0.pre.alpha3, 8.0.0.pre.alpha4, 8.0.0.pre.beta, 8.0.0, 8.0.1, 8.1.0, 8.2.0, 8.2.1, 9.0.0, 9.0.1, 9.1.0, 9.1.1, 9.2.0, 9.3.0, 9.4.0, 9.5.0, 9.5.1, 9.6.0, 9.6.1, 9.7.2, 10.0.0, 10.1.0, 10.1.1, 11.0.0, 11.1.0, 11.3.0, 11.4.0, 11.5.0, 12.0.0, 12.1.0, 12.2.0, 13.0.0

解决方法

1. 手动指定版本安装Box

直接执行命令安装13.0.0版本的Homestead Box:

vagrant box add laravel/homestead --box-version 13.0.0

安装完成后再执行vagrant up即可正常启动。

2. 修改版本约束

打开Homestead配置文件(Homestead.yaml或Homestead.json),找到版本约束相关配置,将其调整为>=13.0.0或者直接指定13.0.0,保存后重新执行vagrant up。

3. 检查网络连接

如果手动安装失败,检查本地网络是否能正常访问Vagrant Box源,确保网络通畅后再重试安装操作。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 05:17:35