How can I update Ruby version 2.0.0 to the latest version in Mac OS X v10.10 (Yosemite)?
Categories:
Upgrading Ruby on macOS Yosemite (10.10) to the Latest Version

Learn how to safely and effectively update your Ruby installation from version 2.0.0 to a more recent version on macOS Yosemite (10.10) using rbenv
or RVM
.
Ruby 2.0.0, while functional, is an outdated version that lacks many modern features, performance improvements, and crucial security patches. Running an old version can lead to compatibility issues with newer gems and applications, and expose your system to known vulnerabilities. This guide will walk you through the process of upgrading Ruby on macOS Yosemite (10.10) to a more current version, focusing on using version managers like rbenv
or RVM
for a clean and flexible setup.
Why Use a Ruby Version Manager?
macOS comes with a system-wide Ruby installation, often referred to as 'system Ruby'. Modifying this system Ruby directly is highly discouraged as it can break system utilities that rely on it. Ruby version managers like rbenv
and RVM
(Ruby Version Manager) provide a safe and isolated way to install and manage multiple Ruby versions without interfering with the system Ruby. They allow you to easily switch between different Ruby versions for various projects, ensuring compatibility and stability.
flowchart TD A[Start: Current Ruby 2.0.0] --> B{Choose Version Manager} B --> C[Install Homebrew] C --> D{Install rbenv or RVM} D --> E[Install Latest Ruby Version] E --> F[Set Global/Local Ruby] F --> G[Verify Installation] G --> H[End: Latest Ruby Version]
High-level process for upgrading Ruby using a version manager.
Prerequisites: Homebrew Installation
Before installing a Ruby version manager, you'll need to ensure you have Homebrew installed. Homebrew is a package manager for macOS that simplifies the installation of development tools. If you don't have it, open your Terminal and run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Homebrew on macOS
Follow the on-screen instructions to complete the installation. You might be prompted to install Xcode Command Line Tools if they are not already present. After installation, run brew doctor
to check for any issues and brew update
to ensure Homebrew is up-to-date.
Method 1: Upgrading Ruby with rbenv
rbenv
is a lightweight Ruby version manager that uses shims to manage Ruby versions. It's generally preferred for its simplicity and non-intrusive nature.
1. Step 1: Install rbenv and ruby-build
Use Homebrew to install rbenv
and ruby-build
. ruby-build
is an rbenv
plugin that allows you to compile and install different Ruby versions.
2. Step 2: Configure your shell
Add rbenv
to your shell's initialization file (e.g., ~/.bash_profile
, ~/.zshrc
). This ensures rbenv
loads every time you open a new terminal session.
3. Step 3: Install the desired Ruby version
Find the latest stable Ruby version available (e.g., ruby-3.2.2
). You can list available versions using rbenv install -l
. Then, install your chosen version.
4. Step 4: Set the global Ruby version
Once installed, set the newly installed Ruby version as your global default. You can also set a local version for specific projects using rbenv local <version>
.
5. Step 5: Verify the installation
Confirm that your system is now using the new Ruby version.
# Step 1: Install rbenv and ruby-build
brew install rbenv ruby-build
# Step 2: Configure your shell (for Bash)
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
# For Zsh users, use ~/.zshrc instead:
# echo 'eval "$(rbenv init -)"' >> ~/.zshrc
# source ~/.zshrc
# Step 3: Install the desired Ruby version (e.g., 3.2.2)
rbenv install 3.2.2
# Step 4: Set the global Ruby version
rbenv global 3.2.2
# Step 5: Verify the installation
ruby -v
Commands for installing and configuring Ruby with rbenv
3.2.2
with the actual latest stable Ruby version you wish to install. Always check rbenv install -l
for available versions.Method 2: Upgrading Ruby with RVM
RVM
is another popular Ruby version manager that offers more features, including gemset management. It's a more comprehensive solution but can be perceived as heavier than rbenv
.
1. Step 1: Install RVM
Install RVM using its official installation script. This will also install the necessary GPG keys.
2. Step 2: Load RVM into your shell
After installation, you need to load RVM into your current shell session. It typically modifies your shell configuration files automatically.
3. Step 3: Install the desired Ruby version
List available Ruby versions and then install the latest stable one.
4. Step 4: Set the default Ruby version
Set the newly installed Ruby version as your default. You can also use rvm use <version> --create
to create a gemset for a specific project.
5. Step 5: Verify the installation
Check your current Ruby version to confirm the upgrade.
# Step 1: Install RVM
curl -sSL https://get.rvm.io | bash -s stable --ruby
# Step 2: Load RVM into your shell (if not automatically loaded)
source ~/.rvm/scripts/rvm
# Step 3: Install the desired Ruby version (e.g., 3.2.2)
rvm install 3.2.2
# Step 4: Set the default Ruby version
rvm use 3.2.2 --default
# Step 5: Verify the installation
ruby -v
Commands for installing and configuring Ruby with RVM
Post-Installation Steps
After successfully installing a newer Ruby version, you'll likely need to reinstall any gems you were using with your old Ruby 2.0.0 setup. Navigate to your project directory and run bundle install
if you're using Bundler, or manually install gems with gem install <gem_name>
.
cd /path/to/your/project
bundle install
# Or for individual gems:
gem install rails
gem install jekyll
Reinstalling gems after Ruby upgrade