简体   繁体   中英

RVM installing but no Rubies with Chef-solo and Vagrant?

I am using Chef-solo, Berkshelf and Vagrant to try to build a development environment. I have other recipes working but the ' chef-rvm ' cookbook is giving me trouble for getting a ruby version installed.

To be clear, RVM is installing but when I ' vagrant ssh ' into the vbox and type ' rvm list ' it says there are no rubies installed. I can type ' rvm install 2.1.1 ' and it works so I'm not sure why Chef isn't installing it.

Vagrantfile:

config.vm.provision :chef_solo do |chef|
  chef.run_list = %w[
    recipe[apt::default]
    recipe[rvm::user_install]
    recipe[rvm::vagrant]
  ]
end

recipes/default.rb:

include_recipe 'apt'
include_recipe 'rvm::user_install'

attributes/default.rb:

    node.set['rvm']['user_installs'] = [
    { 'user'            => 'vagrant',
      'upgrade'         => 'head',
      'default_ruby'    => '2.1.1',
      'rvm_gem_options' => '',
      'rubies' => ['2.1.1', '2.0.0-p481'],
      'global_gems'     => [
          { 'name'    => 'bundler',
            'version' => '1.6.2'
          },
          { 'name'    => 'rake' },
          { 'name'    => 'rails' },
          { 'name'    => 'rubygems-bundler',
            'action'  => 'remove'
          }
      ]
    }
]

I thought it should be the default action, but I have the same problem as you. My solution was to include the " install_ruby " property in the json config:

node.set['rvm']['user_installs'] = [
    { 'user'            => 'vagrant',
       install_rubies: true,
       ...
    }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM