Laravel homestead 无法执行 Vagrant Up 错误约束:>= 13.0.0,< 14.0.0

问题描述 投票:0回答:1

这是流浪者文件

# -*- 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,但是当我启动时出现错误 **

流浪起来 将机器“宅基地”与“virtualbox”提供商一起使用...... ==> homestead:找不到“laravel/homestead”框。正在尝试查找并安装... homestead:Box 提供商:virtualbox homestead:Box 版本:>= 13.0.0,< 14.0.0 ==> homestead:加载框“laravel/homestead”的元数据 家园:网址:https://vagrantcloud.com/api/v2/vagrant/laravel/homestead 您尝试添加的框没有可用的版本 符合您要求的约束。请仔细检查您的 设置。另请验证是否指定了版本限制, 您希望使用的提供商可以满足这些限制。

盒子:laravel/homestead 地址:https://vagrantcloud.com/api/v2/vagrant/laravel/homestead 限制:>= 13.0.0,< 14.0.0 Available versions: 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

laravel vagrant virtual-machine version vagrantfile
1个回答
0
投票

您遇到的错误表明没有“laravel/homestead”版本满足您指定的版本约束。 你可以像这样在 vagrant 文件中指定 vagrant 版本

我添加了这个:

config.vm.box =“laravel/homestead” config.vm.box_version = "13.0.0" # 在此指定box版本

# -*- 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"
  config.vm.box_version = "13.0.0"  # Specify the box version here

  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

© www.soinside.com 2019 - 2024. All rights reserved.