Skip to content

Updating a Ruby Version on a Remote Server

Upgrading the Ruby version on our self-built servers (e.g., AWS, Rackspace, Tgen, etc.) is a crucial task that requires careful planning and execution. The Ruby version needs to be updated before deploying any codebase that depends on the newer Ruby version; otherwise, the deployment will fail due to unsatisfied dependencies.

This page serves as a guide for engineers to properly update Ruby versions on remote servers. Always test these changes in a staging environment before applying them to production.


The steps to upgrade Ruby versions can be divided into these high-level tasks:

  1. SSH into the staging server(s) for initial testing.
  2. Update the ruby-build database.
  3. Install the new Ruby version using rbenv.
  4. Update the local version of Ruby using rbenv.
  5. Install the desired version of Bundler.
  6. Update the global Ruby version with rbenv.

Always start by testing out the upgrade on a staging server. SSH into the desired server:

Terminal window
ssh [user]@[staging_server_ip]

Replace [user] and [staging_server_ip] with appropriate values.


Navigate to the directory where ruby-build is installed and update its database:

Terminal window
cd /home/deploy/.rbenv/plugins/ruby-build && git pull && cd -

This ensures that rbenv will have access to the latest Ruby versions.


Install the new Ruby version using rbenv. Replace 2.4.1 with the version you wish to install:

Terminal window
rbenv install 2.4.1

Update the local rbenv version to the newly installed version:

Terminal window
rbenv local 2.4.1

This sets the version of Ruby that the local user will use.


Install the Bundler version that you want to be available on the server. Replace 1.17.3 with the desired version:

Terminal window
gem install bundler --version 1.17.3

Note: Do this step only when you are ready to deploy the changes to the server.

Set the global Ruby version to the newly installed version:

Terminal window
rbenv global 2.4.1

You have successfully updated the Ruby version on the remote server. Before moving to production, validate that all the applications and services are running as expected in the staging environment.


  • Backups: Ensure you have proper backups before initiating any upgrade process.
  • Monitoring: Monitor the server’s performance after the upgrade for any unusual behavior.
  • Documentation: Keep a log of version changes and any issues encountered for future reference.
  • Team Communication: Always notify the team about the upgrade plans and execution status.