# Rvm and chef ruby

**URL:** <https://discourse.chef.io/t/rvm-and-chef-ruby/7174>\
**Category:** Chef Infra (archive)\
**Created:** [October 25, 2015, 5:45am UTC](https://discourse.chef.io/t/rvm-and-chef-ruby/7174 "2015-10-25T05:45:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![okram999](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/okram999/32/1083_2.png) [@okram999](https://discourse.chef.io/u/okram999)\
**Post date:** [October 25, 2015, 5:45am UTC](https://discourse.chef.io/t/rvm-and-chef-ruby/7174/1 "2015-10-25T05:45:30Z")

</div>

Hey guys, i have been wondering if we should not be using rvm or any other  
versions of ruby with chef. I have rvm installed in my chef devel  
workstation (ubuntu 12.04). I have repos/workspace where i create custom  
mulitple cookbooks (some uses the community cookbooks) specific to  
projects. Each workspace have the ‘.ruby-version’ and ‘.ruby-gemset’ files.

Based on the chef doc to install chefDK  
[https://docs.chef.io/install\_dk.html](https://docs.chef.io/install_dk.html), it says to use the chef ruby as the  
system ruby by using this command.

echo ‘eval “$(chef shell-init bash)”’ \>\> ~/.bash\_profile

The above command doesn’t like to be in the ~/.bash\_profile so, i  
placed it in ~/.bashrc file and works.

Now, i had a similar issue after installing the rvm (system-wide).  
Ubuntu wont source the /etc/profile.d/rvm.sh  
[http://askubuntu.com/questions/40287/etc-profile-not-being-sourced](http://askubuntu.com/questions/40287/etc-profile-not-being-sourced).  
So, i had to place the

below entry in the ~/.bashrc file again. So the new entries in the  
~/.bashrc files are:

####Added by me  
[[-s “/etc/profile.d/rvm.sh”]] && . “/etc/profile.d/rvm.sh” # Load  
RVM function  
####added by me  
eval “$(chef shell-init bash)” #loads chefdk ruby

With these entries now, whenever a new shell is started i am greeted  
by the below warning:

Warning! PATH is not properly set up,  
’/home/user/.chefdk/gem/ruby/2.1.0/bin’ is not at first place,  
usually this is caused by shell initialization files - check  
them for ‘PATH=…’ entries,  
it might also help to re-add RVM to your dotfiles: ‘rvm get  
stable --auto-dotfiles’,  
to fix temporarily in this shell session run: ‘rvm use 2.1.0’.

---

<div class="post-metadata">

**Author:** ![Lamont\_Granquist](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Lamont\_Granquist](https://discourse.chef.io/u/Lamont_Granquist)\
**Post date:** [October 26, 2015, 5:58pm UTC](https://discourse.chef.io/t/rvm-and-chef-ruby/7174/2 "2015-10-26T17:58:56Z")

</div>

I’ve been experimenting with having rvm take priority over chef-dk (init chef-dk and then init RVM) and then use ‘system’ in a project .ruby-version so that if i ‘cd’ into certain directories i’ll get chef-dk instead of rvm ruby.

There’s also ‘rvm mount’ to load the chef-dk ruby into rvm, but i ran into issues making that auto switch based on .ruby-version or .rvmrc (i think?)

---

<div class="post-metadata">

**Author:** ![okram999](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/okram999/32/1083_2.png) [@okram999](https://discourse.chef.io/u/okram999)\
**Post date:** [October 29, 2015, 11:52pm UTC](https://discourse.chef.io/t/rvm-and-chef-ruby/7174/3 "2015-10-29T23:52:33Z")

</div>

Using chefDK 0.9.0’s ruby - it ties down to ruby 2.1.0 only. So it doesn;t give an env to work with a different workspace which use another version of ruby without the rvm installed
