sous-chefs/vagrant

vagrant_plugin :install fails on Windows in `vagrant_get_home` w/ undefined method `dir' for nil:NilClass

dougireton opened this issue · 3 comments

Using the vagrant_plugin resource fails on Windows because the vagrant_get_home helper relies on Ruby's Unix-only Etc module:

https://github.com/jtimberman/vagrant-cookbook/blob/master/libraries/helpers.rb#L62

Repro

A Windows test-kitchen run fails with this stacktrace:

       Recipe: vagrant::install_plugins
         * vagrant_plugin[vagrant-winrm] action install[2015-10-18T16:12:56-07:00] INFO: Processing vagrant_plugin[vagrant-winrm] action install (vagrant::install_plugins line 28)
       [2015-10-18T16:12:59-07:00] DEBUG: Providers for generic vagrant_plugin resource enabled on node include: [LWRP provider vagrant_plugin from cookbook vagrant]
       [2015-10-18T16:12:59-07:00] DEBUG: Provider for action install on resource vagrant_plugin[vagrant-winrm] is LWRP provider vagrant_plugin from cookbook va
grant
       [2015-10-18T16:13:00-07:00] DEBUG: I found a string for `vagrant`
       [2015-10-18T16:13:01-07:00] DEBUG: I found a string for `vagrant`
       [2015-10-18T16:13:02-07:00] DEBUG: Attempting to get $HOME of vagrant


           ================================================================================
           Error executing action `install` on resource 'vagrant_plugin[vagrant-winrm]'
           ================================================================================

           NoMethodError
           -------------
           undefined method `dir' for nil:NilClass

           Resource Declaration:
           ---------------------
           # In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vagrant/recipes/install_plugins.rb

            28:     vagrant_plugin plugin do
            29:       user node['vagrant']['user']
            30:     end
            31:

           Compiled Resource:
           ------------------
           # Declared in C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vagrant/recipes/install_plugins.rb:28:in `block in from_file'

           vagrant_plugin("vagrant-winrm") do
             action [:install]
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :vagrant_plugin
             cookbook_name "vagrant"
             recipe_name "install_plugins"
             user "vagrant"
           end

       [2015-10-18T16:13:25-07:00] INFO: Running queued delayed notifications before re-raising exception
       [2015-10-18T16:13:27-07:00] DEBUG: Re-raising exception: NoMethodError - vagrant_plugin[vagrant-winrm] (vagrant::install_plugins line 28) had an error: N
oMethodError: undefined method `dir' for nil:NilClass
       C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vagrant/libraries/helpers.rb:77:in `vagrant_get_home'
         C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vagrant/providers/plugin.rb:91:in `vagrant_home'
         C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/vagrant/providers/plugin.rb:28:in `load_current_resource'
         C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1-universal-mingw32/lib/chef/provider.rb:127:in `run_action'
         C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1-universal-mingw32/lib/chef/resource.rb:585:in `run_action'
         C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1-universal-mingw32/lib/chef/runner.rb:49:in `run_action'
       rb:81:in `block (2 levels) in converge'
         C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1-universal-mingw32/lib/chef/runner.rb:81:in `each'
         C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1-universal-mingw32/lib/chef/runner.rb:81:in `block in converge'

Any reason not to use Ruby's Dir.home method?

This should be fixed as a separate PR after #39 is merged.

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.