Vagrant:vagrant up命令给出"必须指定一个框"错误

Lan*_*ara 5 terminal virtualbox vagrant laravel homestead

我在尝试运行"vagrant up"终端命令时遇到此错误:

本机的配置存在错误.请修正以下错误,然后重试:

*必须指定一个方框.

在我的Homestead/.vagrant/machines/default/virtualbox文件夹中,那里没有文件,所以我假设它是指它必须指定一个盒子的时候,但是我不知道如何包含一个盒子,因为这是我第一次使用vagrant,我没有决心在网上搜索.

有人有解决方案吗?

编辑(Vagrantfile):

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")

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

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

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end
Run Code Online (Sandbox Code Playgroud)

tro*_*gne 6

在宅基目录中,您必须运行该命令bash init.sh.

这将生成Homestead.yaml文件(after.sh和aliases)你的主目录内的(~).

如果您Homestead.yaml再次更换,则必须重新运行bash init.sh.它会要求覆盖,说是.

(另外,请确保folders: - map:存在的目录)


Lan*_*ara 3

通过修复 homestead.yaml 中的文件路径解决了这个问题。当我在终端中进行安装时,正在主 Homestead 文件夹之外创建一个 .homestead 文件夹,这就是导致我的问题的原因。但是,将 .homestead/homestead.yaml 中的路径更改为我的 Homestead/homestead.yaml 中的相同路径后,问题不再存在。