Rbenv vagrant全球红宝石版本不变

时间:2013-09-04 14:33:22

标签: ruby chef vagrant berkshelf

我正在使用Vagrant和Berkshelf插件创建一个默认使用Ruby 2.0.0-p247的Ubuntu 12.04计算机。当机器加载时,ruby -v返回ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux],表示rbenv尚未安装正确的版本。

此外,如果我尝试rbenv global 2.0.0-p247我收到错误rbenv: version 2.0.0-p247'未安装'

任何想法我做错了什么?

由于

Vagrantfile:

config.berkshelf.enabled = true

config.omnibus.chef_version = :latest

config.vm.provision :shell, :inline => "gem install chef --no-rdoc --no-ri --conservative"

config.vm.provision :chef_solo do |chef|
chef.add_recipe "apt"
chef.add_recipe "git"
chef.add_recipe "build-essential"
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::vagrant"
chef.add_recipe "rbenv::system"

chef.json = {
  'rbenv' => {
    'user_installs' => [
      {
        'user'    => 'vagrant',
        'rubies'  => ['2.0.0-p247'],
        'global'  => '2.0.0-p247',
        'gems'    => {
          '2.0.0-p247' => [
            { 'name'    => 'bundler' },
            { 'name'    => 'rake' }
          ]
        }
      }
    ]
    }
  }
end

Berksfile:

site :opscode

cookbook 'apt'
cookbook 'git'
cookbook 'build-essential'
cookbook 'ruby_build'
cookbook 'rbenv', git: 'git://github.com/fnichol/chef-rbenv.git', ref: "v0.7.2"

1 个答案:

答案 0 :(得分:4)

您正在使用rbenv食谱安装用户Rubies。在您的情况下,rbenv::system配方什么都不做,因为您没有指定要安装的任何系统Ruby。

相反,请添加rbenv::user食谱:

...
chef.add_recipe "ruby_build"
chef.add_recipe "rbenv::vagrant"
chef.add_recipe "rbenv::user"     ### This is the recipe you want

chef.json = {
  'rbenv' => {
    'user_installs' => [
      {
        'user'    => 'vagrant',
        'rubies'  => ['2.0.0-p247'],
...