laravel Vagrant:vagrant up 命令给出“必须指定一个框”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31666426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vagrant: vagrant up command gives "A box must be specified" error
提问by Lansana Camara
I am getting this error when trying to run the "vagrant up" terminal command:
尝试运行“vagrant up”终端命令时出现此错误:
There are errors in the configuration of this machine. Please fix the following errors and try again:
*A box must be specified.
这台机器的配置有错误。请修复以下错误并重试:
*必须指定一个框。
In my Homestead/.vagrant/machines/default/virtualbox
folder, there is no file there, so I'm assuming that is what it's referring to when it says a box must be specified, however I don't know how to include a box as this is my first time using vagrant, and I've searched online with no resolve.
在我的Homestead/.vagrant/machines/default/virtualbox
文件夹中,那里没有文件,所以我假设当它说必须指定一个框时它指的是什么,但是我不知道如何包含一个框,因为这是我第一次使用 vagrant,我在网上搜索没有解决。
Anyone have a solution to this?
任何人都有解决方案?
EDIT (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
采纳答案by Lansana Camara
Fixed this by fixing my file paths in the homestead.yaml. When I made the installs in the terminal, a .homestead folder was being create outside of the main Homestead folder, which is what was causing my problems. But after changing the paths inside that .homestead/homestead.yaml to the same ones in my Homestead/homestead.yaml, the problem no longer persisted.
通过在 homestead.yaml 中修复我的文件路径来解决这个问题。当我在终端中进行安装时,在主 Homestead 文件夹之外创建了一个 .homestead 文件夹,这就是导致我出现问题的原因。但是在将 .homestead/homestead.yaml 中的路径更改为我的 Homestead/homestead.yaml 中的相同路径后,问题不再存在。
回答by trogne
Inside the homestead directory, you have to run the command bash init.sh
.
在 homestead 目录中,您必须运行命令bash init.sh
.
This will generate the Homestead.yaml
file (and after.sh
and aliases
) inside your home directory (~
).
这将在您的主目录 ( ) 中生成Homestead.yaml
文件(和after.sh
和)。aliases
~
If you are changing Homestead.yaml
again, you have to re-run bash init.sh
again. It will ask for overwrite, say yes.
如果Homestead.yaml
再次更改,则必须重新运行bash init.sh
。它会要求覆盖,说是。
(also, be sure that the directory for folders: - map:
exists)
(另外,请确保目录folders: - map:
存在)
回答by Maxim Lanin
Use homestead up
instead of vagrant up
, if you are using homestead package. It already knows where all files are and will up you VM easily.
如果您使用 homestead 包,请使用homestead up
代替vagrant up
。它已经知道所有文件的位置,并且可以轻松启动您的虚拟机。