Vagrant:vagrant up 命令给出 "A box must be specified" 错误
Vagrant: vagrant up command gives "A box must be specified" error
我在尝试 运行 "vagrant up" 终端命令时遇到此错误:
There are errors in the configuration of this machine. Please fix the following errors and try again:
*A box must be specified.
在我的 Homestead/.vagrant/machines/default/virtualbox
文件夹中,那里没有文件,所以我假设这就是它所说的必须指定一个框时所指的内容,但是我不知道如何包含一个box,因为这是我第一次使用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
如果您使用的是 homestead 包,请使用 homestead up
而不是 vagrant up
。它已经知道所有文件的位置,并且可以轻松启动您的虚拟机。
通过在 homestead.yaml 中修复我的文件路径来解决这个问题。当我在终端中进行安装时,在主 Homestead 文件夹之外创建了一个 .homestead 文件夹,这就是导致我出现问题的原因。但是在将 .homestead/homestead.yaml 中的路径更改为我的 Homestead/homestead.yaml 中的相同路径后,问题不再存在。
在 homestead 目录中,您必须 运行 命令 bash init.sh
。
这将在您的主目录 (~
) 中生成 Homestead.yaml
文件(以及 after.sh
和 aliases
)。
如果要再次更改Homestead.yaml
,则必须重新运行 bash init.sh
。它会要求覆盖,说是。
(另外,确保 folders: - map:
的目录存在)
我在尝试 运行 "vagrant up" 终端命令时遇到此错误:
There are errors in the configuration of this machine. Please fix the following errors and try again:
*A box must be specified.
在我的 Homestead/.vagrant/machines/default/virtualbox
文件夹中,那里没有文件,所以我假设这就是它所说的必须指定一个框时所指的内容,但是我不知道如何包含一个box,因为这是我第一次使用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
如果您使用的是 homestead 包,请使用 homestead up
而不是 vagrant up
。它已经知道所有文件的位置,并且可以轻松启动您的虚拟机。
通过在 homestead.yaml 中修复我的文件路径来解决这个问题。当我在终端中进行安装时,在主 Homestead 文件夹之外创建了一个 .homestead 文件夹,这就是导致我出现问题的原因。但是在将 .homestead/homestead.yaml 中的路径更改为我的 Homestead/homestead.yaml 中的相同路径后,问题不再存在。
在 homestead 目录中,您必须 运行 命令 bash init.sh
。
这将在您的主目录 (~
) 中生成 Homestead.yaml
文件(以及 after.sh
和 aliases
)。
如果要再次更改Homestead.yaml
,则必须重新运行 bash init.sh
。它会要求覆盖,说是。
(另外,确保 folders: - map:
的目录存在)