Mad-D
Mad-D

Reputation: 4669

cannot load such file -- ruby-wmi (LoadError) & cannot load such file -- win32/service (LoadError)

I did install below mentioned ruby stuff

enter image description here

when i try executing chef-client, i receive below mentioned error

c:\RubyDevKit>chef-client
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- ruby-wmi (LoadError)
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-10.14.4/lib/chef/provider/env/windows.rb:20:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-10.14.4/lib/chef/providers.rb:49:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-10.14.4/lib/chef.rb:25:in `<top (required)>'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/chef-10.14.4/bin/chef-client:23:in `<top (required)>'
        from C:/Ruby193/bin/chef-client:23:in `load'
        from C:/Ruby193/bin/chef-client:23:in `<main>'

Ruby193 folder Structure ( Missing )

enter image description here

Upvotes: 8

Views: 9253

Answers (3)

DivineOps
DivineOps

Reputation: 1686

Newer versions of Chef do not use ruby-wmi, so you should not need the gem. I got this error while trying to run test kitchen, and I have tried the solutions above but they didn't work.

This worked for me:

  • Uninstall and re-install Vagrant
  • Delete C:\Users\USERNAME.vagrant.d\gems folder
  • Delete C:\Users\USERNAME.vagrant.d\plugins.json file

After that kitchen runs fine.

Upvotes: 0

Mad-D
Mad-D

Reputation: 4669

As Prakash Murthy said, It was missing ruby-wmi files. Thought it will help if anyone get stuck again

I did run these commands

C:\> gem install win32-open3 ruby-wmi windows-api windows-pr --no-rdoc --no-ri --verbose
C:\> gem install rdp-ruby-wmi

Got one more error

C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- win32/service (LoadError)

So i would recommend

(i) check gem installed ( in CMD )

gem list

this will pointout missing gems, in my case win32/service was misisng

(ii) gem install win32-service

check gem list again to make sure & should fix the problems.

Upvotes: 7

Prakash Murthy
Prakash Murthy

Reputation: 13067

The error message cannot load such file -- ruby-wmi (LoadError) is coming up because chef-client cannot find the required gems.

This issue is addressed on the Opscode/Chef wiki page on Common Errors.

As mentioned there, install the required gems with the following commands:

C:\> gem install win32-open3 ruby-wmi windows-api windows-pr --no-rdoc --no-ri --verbose
C:\> gem install rdp-ruby-wmi

Upvotes: 10

Related Questions