1

I have included rvm --create --ruby-version ruby-2.3.3@storesview in my recipe to create a gemset. Running the kitchen converge does not result in the creation of .ruby-gemset and .ruby-version. But when I run rvm --create --ruby-version ruby-2.3.3@storesview directly on the VM terminal, the files are getting created. What could be the reason? Thanks. Here's what my bash code looks like :

bash "somename" do
  user 'root'
  cwd "/var/www/html/APIStoresView/"
  code <<-EOH
    rvm --create --ruby-version ruby-2.3.3@storesview
  EOH
end
Anjana
  • 45
  • 1
  • 6
  • Just because you're running from an environment where ruby and gem path are fixed by chef ruby itself ? When you're in command line your not. Either you'll have to set the proper environment variable in your bash command or have a look at other cookbooks for this (rbenv maybe) – Tensibai Dec 16 '16 at 09:25
  • Sorry for sounding naive, but how do we set env variables? Also what are the values for the env variables? – Anjana Dec 16 '16 at 10:13
  • 1
    For setting the env values, it's in the [documentation](https://docs.chef.io/resource_bash.html#properties), the values have to be given by `rvm env` after a `rvm use`. but consider following the advice you did get on slack. Mainly moving to poise_ruby or rbenv. – Tensibai Dec 16 '16 at 10:23

1 Answers1

1

In general use of rvm on servers should be discouraged, and Chef+rvm is dicey at the best of times. More specifically, appbundler (used by Chef to create marginally bullet proof binary stubs) sets a lot of environment variables that can confuse rvm.

If you need a specific version of Ruby for a project, I would highly recommend using poise-ruby+poise-ruby-build and Bundler rather than rvm and gemsets.

coderanger
  • 52,400
  • 4
  • 52
  • 75