vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Properly validate box metadata.json content

Open andy65007 opened this issue 3 years ago • 3 comments

when I add a self-made box, below error shows, I think this is similar to #3806. [root@dev1 14:30 /home/vagrant/win7-64]vagrant box add my-win7-64 my-win7-64.box

==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'my-win7-64' (v0) for provider: box: Unpacking necessary files from: file:///home/vagrant/win7-64/my-win7-64.box Traceback (most recent call last): 21: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/bin/vagrant:231:in <main>' 20: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/environment.rb:290:in cli' 19: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/cli.rb:67:in execute' 18: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/commands/box/command/root.rb:66:in execute' 17: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/commands/box/command/add.rb:78:in execute' 16: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/runner.rb:89:in run' 15: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/util/busy.rb:19:in busy' 14: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/runner.rb:89:in block in run' 13: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/builder.rb:149:in call' 12: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/warden.rb:48:in call' 11: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/builtin/box_add.rb:129:in call' 10: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/builtin/box_add.rb:155:in add_direct' 9: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/action/builtin/box_add.rb:372:in box_add' 8: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:104:in add' 7: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:456:in with_collection_lock' 6: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:456:in synchronize' 5: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:457:in block in with_collection_lock' 4: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:115:in block in add' 3: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:470:in with_temp_dir' 2: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:134:in block (2 levels) in add' 1: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:470:in with_temp_dir' /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/box_collection.rb:156:in block (3 levels) in add': undefined method `to_sym' for nil:NilClass { "name": "my-win7-64", "description": "My Custom Windows 7 64-bit Box", "versions": [{ "version": "1.0.0", "providers": "vmware_esxi" }] }

Below is the list of my box file: drwxr-xr-x 1 root root 73728 May 19 06:31 . drwxr-xr-t 1 root root 77824 May 19 03:33 .. -rw-r--r-- 1 root root 197 May 19 02:28 metadata.json -rw------- 1 root root 21474836480 May 19 04:21 win7-64-flat.vmdk -rw------- 1 root root 8684 May 19 04:19 win7-64.nvram -rw------- 1 root root 473 May 19 04:20 win7-64.vmdk -rw-r--r-- 1 root root 0 May 19 03:34 win7-64.vmsd -rwxr-xr-x 1 root root 3125 May 19 04:21 win7-64.vmx

andy65007 avatar May 19 '22 07:05 andy65007

[root@dev1 15:04 /home/vagrant/win7-64]vagrant version

Installed Version: 2.2.19 Latest Version: 2.2.19

You're running an up-to-date version of Vagrant!

andy65007 avatar May 19 '22 07:05 andy65007

Could you share your Vagrantfile, it seems that box.provider is not set correctly.

mrzasa avatar May 19 '22 07:05 mrzasa

Hi there,

In your metadata.json file, the "providers" entry needs to be updated to "provider".

Marking this for enhancement to include proper error checking + descriptive error message on metadata.json content validation.

Cheers!

chrisroberts avatar Jul 12 '22 17:07 chrisroberts

I believe this is resolved by https://github.com/hashicorp/vagrant/pull/12895

soapy1 avatar Jan 13 '23 23:01 soapy1