Skip to content

Instantly share code, notes, and snippets.

@ideaoforder
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideaoforder/45a77228b49c794fcb7a to your computer and use it in GitHub Desktop.
Save ideaoforder/45a77228b49c794fcb7a to your computer and use it in GitHub Desktop.
Rbenv Ruby Upgrade
Install Ruby 2.2.2
cd ~/.rbenv/plugins/ruby-build
git pull
rbenv install 2.2.2

https://github.com/sstephenson/rbenv

Set the current shell to use it, and prepare for Rails - This won't affect current install
rbenv shell 2.2.2
gem install bundler
bundle install
rbenv rehash
When the above works correctly, it should be safe to deploy and set the shell permanently
rbenv global 2.2.2
rbenv which rake # Make sure we're defaulting to the correct ruby
We also need to make rbenv aware of gem's binaries, or the console and CLI won't work
mkdir -p ~/.rbenv/plugins
cd ~/.rbenv/plugins
git clone https://github.com/ianheggie/rbenv-binstubs.git 
cd YOUR_APP
bundle install --binstubs .bundle/bin
rbenv rehash

https://github.com/ianheggie/rbenv-binstubs https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs (This approach didn't work for me)

Alternativelty, you can just install the same gems to the local env (which seems wrong)
bundle install

NOTE: This means when you upgrade a gem, it has to be upgraded on the server as well

You've also got to update the unicorn file in /etc/init.d to use ruby version 2.2.2
And now that we're updated, a few resources on optimizing, specifically GC

http://www.collectiveidea.com/blog/archives/2015/02/19/optimizing-rails-for-memory-usage-part-2-tuning-the-gc/ http://tmm1.net/ruby21-rgengc/ http://engineering.freeagent.com/2014/05/23/upgrading-to-ruby-2.1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment