#
# Cookbook Name:: rvm
# Recipe:: default

# Make sure that the package list is up to date on Ubuntu/Debian.
include_recipe "apt" if ['debian', 'ubuntu'].member? node[:platform]

# Make sure we have all we need to compile ruby implementations:
include_recipe "networking_basic"
include_recipe "build-essential"
include_recipe "git"
include_recipe "libyaml"
include_recipe "libgdbm"

case node[:platform]
when "debian","ubuntu"
  %w(libreadline5-dev libssl-dev libxml2-dev libxslt1-dev zlib1g-dev).each do |pkg|
    package pkg
  end
end

bash "install RVM" do
  user        "vagrant"
  cwd         "/home/vagrant"
  environment Hash['HOME' => "/home/vagrant", 'rvm_user_install_flag' => '1']
  code        <<-SH
  curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer
  chmod +x rvm-installer
  ./rvm-installer --version #{node.rvm.version}
  SH
  not_if      "test -d /home/vagrant/.rvm"
end

cookbook_file "/etc/profile.d/rvm.sh" do
  owner "vagrant"
  group "vagrant"
  mode 0755
end

cookbook_file "/home/vagrant/.rvmrc" do
  owner "vagrant"
  group "vagrant"
  mode  0755

  source "dot_rvmrc.sh"
end

#
# Cookbook Name:: rvm
# Recipe:: default

# Make sure that the package list is up to date on Ubuntu/Debian.
include_recipe "apt" if ['debian', 'ubuntu'].member? node[:platform]

# Make sure we have all we need to compile ruby implementations:
include_recipe "networking_basic"
include_recipe "build-essential"
include_recipe "git"
include_recipe "libyaml"
include_recipe "libgdbm"

case node[:platform]
when "debian","ubuntu"
  %w(libreadline5-dev libssl-dev libxml2-dev libxslt1-dev zlib1g-dev).each do |pkg|
    package pkg
  end
end

bash "install RVM" do
  user        "vagrant"
  cwd         "/home/vagrant"
  environment Hash['HOME' => "/home/vagrant", 'rvm_user_install_flag' => '1']
  code        <<-SH
  curl -s http://rvm.beginrescueend.com/install/rvm -o /tmp/rvm-installer
  chmod +x /tmp/rvm-installer
  /tmp/rvm-installer --version #{node.rvm.version}
  SH
  not_if      "test -d /home/vagrant/.rvm"
end

cookbook_file "/etc/profile.d/rvm.sh" do
  owner "vagrant"
  group "vagrant"
  mode 0755
end

cookbook_file "/home/vagrant/.rvmrc" do
  owner "vagrant"
  group "vagrant"
  mode  0755

  source "dot_rvmrc.sh"
end

Use HTTP to download RVM installer to work around Linux-specific HTTPS download issues with curl
Use HTTP to download RVM installer to work around Linux-specific HTTPS download issues with curl

It may be an rvm.beginrescueend.com certificate issue, however, I am getting obscure curl issues while installing Ruby 1.9.3
on Linux that point at a potential CA bundle differences between recent Linux releases and OS X [Lion].
