Monday, June 22, 2015

Upgrading Ruby using Sunzi

# rbenv
# $1: ruby version

# This condition will not work if we want to upgrade Ruby. Fix is needed.
if [ -d /usr/local/rbenv ]; then
  echo 'rbenv already installed, skipping.'
  git clone git:// /usr/local/rbenv
  echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/
  echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/
  echo 'eval "$(rbenv init -)"' >> /etc/profile.d/
  chmod +x /etc/profile.d/
  source /etc/profile.d/
  pushd /tmp
    git clone git://
    cd ruby-build
  echo "Compiling Ruby. Grab some hot chocolate, this will take a while..."
  rbenv install $1
  rbenv global $1
  gem install bundler --no-ri --no-rdoc
  rbenv rehash

I had to blow the entire /usr/local/rbenv to force the upgrade. Just specifying the version in sunzi.yml:

  environment: production
  ruby_version: 2.2.2

does not work.