0

我正在尝试将 chef 用于以下(Centos VM):

  • 安装红宝石 1.9.3
  • 创建任何人都可以使用的 gemset ('chef-test')
  • 在“chef-test”gemset 上安装两个 gem(rubocop 和 foodcritic)

我正在使用https://github.com/fnichol/chef-rvm从包装说明书中安装 rvm。

这是我的食谱的一部分,它覆盖了 rvm 食谱,理论上应该执行上述操作:

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'

厨师收敛完成没有错误,但是当我以“teamcity”用户身份登录并执行其中一个宝石时,我得到以下信息:

[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)

我在这里想念什么?当我以用户身份登录时,用户已正确添加到 rvm 组,并且默认情况下会加载正确的 gemset。

4

1 回答 1

1

这与 rubocop 依赖于 ruby​​-progressbar 有关。请参阅https://github.com/jfelchner/ruby-progressbar/issues/73。一种可能的解决方法是将您的 gemfile 更新为小于 < 1.5.0 的版本。

更新:这现在已在 ruby​​-progressbar 1.5.1 中修复。

于 2014-05-14T19:51:02.290 回答