Search code examples
rubyrubygemschef-infrarbenv

How to install gems with system wide rbenv by using chef


I installed rbenv system wide (in /usr/local/rbenv) in my VPS. And I want to install gems by using chef.

I tried like this, but the gem is installed in system default ruby.

gem_package "daemons" do
    action :install
end

How can I install gems in system wide rbenv?

By following coderanger's advice, I installed rbenv cookbook by Berkshelf. After that I edited recipe file like this:

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "2.0.0-p451"

rbenv_gem "daemons" do
    ruby_version "2.0.0-p451"
end

Then I got a error ERROR: No resource, method, or local variable named `rbenv_root_path' for `Chef::Recipe "default"'. How can I solve this problem?


Solution

  • You need to use the rbenv_gem resource.