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

懵懂的女人 提交于 2019-12-07 01:07:27

问题


I did install below mentioned ruby stuff

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 )


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/12868121/cannot-load-such-file-ruby-wmi-loaderror-cannot-load-such-file-win32-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!