문제

I'm trying to use chef for the following (Centos VM):

  • Install ruby 1.9.3
  • Create a gemset ('chef-test') that's available to anyone
  • Install two gems (rubocop and foodcritic) on the 'chef-test' gemset

I am using https://github.com/fnichol/chef-rvm for installing rvm from within a wrapper cookbook.

Here's a segment of my recipe that overrides the rvm cookbook and in theory should be doing the above:

node.override['rvm']['default_ruby'] = 'ruby-1.9.3-p545@chef-test'
node.override[:rvm][:rubies] = [ 'ruby-1.9.3-p545@chef-test' ]
node.override['rvm']['group_users'] = [ 'teamcity' ]

node.override['rvm']['gems'] = {
  'ruby-1.9.3-p545@chef-test' => [
    { 'name'    => 'rubocop',
      'version' => '0.19.1'
    },
    { 'name' => 'foodcritic'}
  ]
}

include_recipe 'rvm::system'

The chef converge completes without errors, but when I login as the 'teamcity' user and execute one of the gems I get the following:

[teamcity@vm02 ~]$ rubocop
/usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/
kernel_require.rb:135:in `require': cannot load such file 
-- ruby-progressbar (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/gems/rubocop-0.19.1/lib/rubocop/formatter/fuubar_style_formatter.rb:3:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/gems/rubocop-0.19.1/lib/rubocop.rb:224:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p545/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/gems/rubocop-0.19.1/bin/rubocop:7:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/bin/rubocop:23:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/bin/rubocop:23:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p545@chef-test/bin/ruby_executable_hooks:15:in `<main>'
    -- ruby-progressbar (LoadError)

What am I missing here? The user is properly added to the rvm group and the proper gemset is loaded by default when I login as the user.

도움이 되었습니까?

해결책

This is related to rubocop having a dependency on ruby-progressbar. See https://github.com/jfelchner/ruby-progressbar/issues/73. A possible work around is to update your gemfile to have a version less than < 1.5.0.

Update: This is now fixed in ruby-progressbar 1.5.1.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top