Vagrant 给流浪汉加盒子
我已经创建了一个新的框用于Hyper-V提供商。当我尝试添加长方体时,它会死掉,如下所示:Vagrant 给流浪汉加盒子,vagrant,vagrantfile,vagrant-windows,Vagrant,Vagrantfile,Vagrant Windows,我已经创建了一个新的框用于Hyper-V提供商。当我尝试添加长方体时,它会死掉,如下所示: PS C:\> vagrant box add sbx-misc-app01 .\img-misc-w2k16.box ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'sbx-misc-app01' (v0) for provider: box:
PS C:\> vagrant box add sbx-misc-app01 .\img-misc-w2k16.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'sbx-misc-app01' (v0) for provider:
box: Unpacking necessary files from: file://C:/img-misc-w2k16.box
box:
C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:156:in `block (3 levels) in add': undefined method `to_sym' for nil:NilClass (NoMethodError)
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:461:in `with_temp_dir'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:134:in `block (2 levels) in add'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:461:in `with_temp_dir'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:115:in `block inadd' from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:448:in `block in with_collection_lock'
from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:447:in `with_collection_lock'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/box_collection.rb:104:in `add'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_add.rb:357:in `box_add'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_add.rb:146:in `add_direct'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_add.rb:120:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builder.rb:116:in `call'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `block in run'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/util/busy.rb:19:in `busy'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `run'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/plugins/commands/box/command/add.rb:78:in `execute'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/plugins/commands/box/command/root.rb:66:in `execute'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/cli.rb:46:in `execute'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/environment.rb:269:in `cli'
from C:/HashiCorp/Vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/bin/vagrant:151:in `<main>'
似乎对盒子的不同方面有些混淆 所以从 Box文件-这是一个压缩(tar、tar.gz、zip)文件 特定于单个提供程序,并且可以包含任何内容。流浪核心 从不使用此文件的内容。相反,它们被通过了 给提供者。因此,VirtualBox文件具有不同的 VMware box文件中的内容等 框目录元数据-这是一个JSON文档(通常交换 在与HashiCorp的“流浪云”(Vagrant Cloud)交互期间,指定 框的名称、说明、可用版本、可用 提供程序和指向每个组件的实际框文件(下一个组件)的URL 提供程序和版本。如果此目录元数据不存在,将显示一个框 文件仍然可以直接添加,但它不支持版本控制 和更新 文件
C:\img-misc-w2k16\metadata.json
是方框文件的一部分-它不同于方框目录元数据(如果要分发方框,请使用),但您共享的内容是方框目录元数据
进一步阅读
在归档文件中,Vagrant需要一个文件:metadata.json。
这是一个与上述框完全无关的JSON文件
目录元数据组件每个框只有一个metadata.json
文件(在box文件中),而一个目录元数据JSON文档
可以描述同一框的多个版本,可能跨越
多个提供商。
metadata.json必须至少包含带有
这个盒子是给你的。Vagrant使用它来验证
盒子。例如,如果您的框是用于VirtualBox的,则
metadata.json如下所示:
{“提供者”:“virtualbox”}
如果没有metadata.json文件或
该文件不包含至少具有“provider”键的有效JSON,
然后,Vagrant将在添加框时出错,因为它无法验证
提供者
因此,当您打包您的盒子时,metadata.json的内容应该如下所示
{
"provider": "hyperv"
}
替换文件内容后,您可以重新打包该框,并且应该能够从此框运行VM。Done and Done。“方框:已成功为‘hyperv’添加方框‘img-misc-w2k16’(v0)!”谢谢您,先生!对于box包中的metadata.json文件可以包含什么内容,是否有模式或其他参考?
{
"provider": "hyperv"
}