Skip to content

Instantly share code, notes, and snippets.

@joemocha
Created February 13, 2012 00:04
Show Gist options
  • Select an option

  • Save joemocha/1811956 to your computer and use it in GitHub Desktop.

Select an option

Save joemocha/1811956 to your computer and use it in GitHub Desktop.
rbenv this Mf'er
namespace :rvm do
task :bootstrap do
run "echo 'Overwrote rvm:bootstrap'"
rbenv_script = <<-SH
#!/bin/bash
#
# And now install rbenv
export PATH=$PATH:$HOME/bin:$HOME/.rbenv/shims
VERSION='#{ruby_version}'
HAVE_RBENV_ALREADY=`which rbenv 2>/dev/null`
if [ $? != 0 ]; then
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your path
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> .bash_profile
echo 'eval "$(rbenv init -)"' >> .bash_profile
source ~/.bash_profile
fi;
# Install ruby-build
HAVE_RUBY_BUILD=`which ruby-build 2>/dev/null`
if [ $? != 0 ]; then
cd /tmp
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build
PREFIX=$HOME ./install.sh
cd $HOME
fi;
# Install Ruby #{ruby_version}
HAVE_CORRECT_VERSION=`rbenv versions | grep $VERSION | wc -l`
if [ $HAVE_CORRECT_VERSION -eq 0 ]; then
rbenv install $VERSION
rbenv global $VERSION
# Rehash!
rbenv rehash
fi;
SH
put rbenv_script, "/tmp/chef-cap-#{rails_env}-rbenv.sh", :mode => "0700"
run "/tmp/chef-cap-#{rails_env}-rbenv.sh"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment