1

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

另外,如果我尝试rbenv global 2.0.0-p247收到错误rbenv: version2.0.0-p247' not installed`

任何想法我做错了什么?

谢谢

流浪文件:

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

伯克斯文件:

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"
4

1 回答 1

4

您正在使用说明书安装用户 Ruby rbenv。在您的情况下,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'],
...
于 2013-09-05T12:34:31.387 回答