frapposelli / vagrant-vcenter

A Vagrant provider for VMware vCenter®
MIT License
106 stars 36 forks source link

in `vcenter_upload_box': undefined method `name' for nil:NilClass (NoMethodError) #42

Open hgch opened 7 years ago

hgch commented 7 years ago

Hi,

I've installed version 0.3.3 and now when im trying create one new vagrant then vcenter_upload_box': undefined methodname'.

I'm using the new template from git

.vagrant.d/gems/gems/vagrant-vcenter-0.3.3/lib/vagrant-vcenter/action/inventory_check.rb:29:in vcenter_upload_box': undefined methodname' for nil:NilClass (NoMethodError) from C:/Users/hgoncalves/.vagrant.d/gems/gems/vagrant-vcenter-0.3.3/lib/vagrant-vcenter/action/inventory_check.rb:130:in vcenter_check_inventory' from C:/Users/hgoncalves/.vagrant.d/gems/gems/vagrant-vcenter-0.3.3/lib/vagrant-vcenter/action/inventory_check.rb:22:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in call' from C:/Users/hgoncalves/.vagrant.d/gems/gems/vagrant-vcenter-0.3.3/lib/vagrant-vcenter/action/connect_vcenter.rb:33:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in call' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builtin/config_validate.rb:25:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/warden.rb:34:in call' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/builder.rb:116:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in block in run' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/util/busy.rb:19:inbusy' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/action/runner.rb:66:in run' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:225:inaction_raw' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:200:in block in action' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/environment.rb:561:inlock' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:186:in call' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:186:inaction' from C:/Users/hgoncalves/.vagrant.d/gems/gems/vagrant-vcenter-0.3.3/lib/vagrant-vcenter/provider.rb:28:in state' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:504:instate' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/machine.rb:145:in initialize' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/vagrantfile.rb:79:innew' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/vagrantfile.rb:79:in machine' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/environment.rb:663:inmachine' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/plugin/v2/command.rb:177:in block in with_target_vms' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/plugin/v2/command.rb:201:incall' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/plugin/v2/command.rb:201:in block in with_target_vms' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/plugin/v2/command.rb:183:ineach' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/plugin/v2/command.rb:183:in with_target_vms' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/commands/up/command.rb:131:ininstall_providers' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/commands/up/command.rb:85:in execute' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/cli.rb:42:inexecute' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/lib/vagrant/environment.rb:302:in cli' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.5/bin/vagrant:174:in

'

aloha commented 7 years ago

Stepped through the code and I see cfg = env[:machine].provider_config and cfg.box is actually Nil. This seems to be the problem. The code assumes .box is not nil and it's probably correct in doing so. I'm not super familiar with vagrant plugin development but it seems the warden is sending a different env[:machine] than expected to the check inventory method. Is this a difference in vagrant versions? I will try an older version and see if it helps.

chinmayb commented 7 years ago

I'm facing the same issue, any suggestions please?

kesterriley commented 7 years ago

I have the same problem, anyone found a solution?

eegilbert commented 7 years ago

/home/user/.vagrant.d/gems/2.2.5/gems/vagrant-vcenter-0.3.3/lib/vagrant-vcenter/action/inventory_check.rb:29:in vcenter_upload_box': undefined methodname' for nil:NilClass (NoMethodError)

vagrant 1.8.6: I get the same error message vagrant 1.9.0: I get the same error message

jrampon commented 7 years ago

Same error here with Vagrant 1.9.1. Going back to the plugin version 0.3.2 works fine.

vagrant plugin install vagrant-vcenter --plugin-version 0.3.2

vladistan commented 7 years ago

Same error here Vagrant 1.8.1 or 1.9.1 plugin version 0.3.3

More information about this. The error started to appear after I added another machine to the Vagrant file that is using new box. When I change the box name to something that is already uploaded to VCenter server as template the error disappears.

Going back to version 0.3.2 makes the error go away

chamap1 commented 7 years ago

Is this going to be fixed?

sdorsett commented 6 years ago

This error affects both vagrant status as well the vagrant up command and seems to be related to lib/vagrant-vcenter/action/inventory_check.rb referencing properties of the box file ( specifically 'name' and 'directory') before the HandleBox action downloads the box file, resulting in env[:machine].box being nil.

One work around I found was I could use vagrant box add to download/stage the box file before initially running vagrant up or vagrant status to prevent env[:machine].box from being nil. The vagrant commands would then behave as expected.

TheSin- commented 2 years ago

looking at the commit that causes the issue

https://github.com/frapposelli/vagrant-vcenter/commit/440c6ab7f66135730f6b73bd067e0ca0ca70a4d1#diff-43751c934090f8d0fd91747614a16681bf709f6a6111698d15c57a319cf48778

I assume it's the missing to_s causing the issue here?