Ruby Installation and Local Development Environment on macOS
Meta description (155 characters): Learn the steps of installing Ruby with Homebrew on macOS, PATH setting and the “Hello World” test program in this guide.
🧠 What Will You Learn in This Guide?
macOS comes with an older version of Ruby by default. In this guide, you will learn how to install the latest and most stable version of Ruby using Homebrew. It will also set up the PATH variable for your system to automatically use this new version and a simple “Hello, World!” You will test the installation with the program.
⚙️ Prerequisites
Before you start the installation, you must have:
- macOS El Capitan (10.11) or later.
- User account with Administrator (sudo) privileges.
- An active internet connection.
1️⃣ Opening Terminal and Installing Xcode Tools
Ruby and Homebrew installation is done via Terminal (Command Line Interface). To access Terminal:
- Follow the steps Finder > Applications > Utilities > Terminal.
- Alternatively, press CMD + SPACE and type “Terminal”.
Run this command to install Xcode Command Line Tools:
xcode-select --install
This command downloads and installs Ruby's build tools. May require license approval.
2️⃣ Installing Homebrew Package Manager
Homebrew is the most popular open source package manager for macOS. It allows you to easily install many software such as Ruby, Python, Node.js.
To install, run the following command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This command downloads Homebrew and installs it with macOS' existing Ruby. If a password is requested, the characters will not appear while typing; This is normal. Press y for confirmation.
3️⃣ Setting the PATH Environment Variable
In order for the tools installed by Homebrew to run first, the PATH variable must be added.
Bash users:
nano ~/.bash_profile
Zsh users (macOS Catalina and later):
nano ~/.zshrc
Add the following line to the end of the opened file:
# Homebrew dizinini PATH'e ekle
export PATH=/usr/local/bin:$PATH
Save and exit (CTRL+O → ENTER → CTRL+X). To enable changes:
source ~/.bash_profile
or
source ~/.zshrc
Test that Homebrew is installed correctly:
brew doctor
“Your system is ready to brew.” message means successful installation.
4️⃣ Ruby Installation and Verification
You are now ready to install Ruby. The following command installs Ruby and the necessary dependencies:
brew install ruby
This command installs the latest version of Ruby (with dependencies such as OpenSSL, libyaml, readline).
Check the version after installation:
ruby -v
Sample output:
ruby 3.2.2p20 (2025-05-10 revision 12345) [x86_64-darwin21]
To keep Ruby up to date:
brew update && brew upgrade ruby
5️⃣ Test Ruby Environment (Hello, World!)
To test that the installation was successful, create a simple Ruby file:
nano merhaba.rb
Add the following code:
puts "Merhaba, Dünya!"
Save and exit (CTRL+X → Y → ENTER) Run the program:
ruby merhaba.rb
Output:
Merhaba, Dünya!If you see this message, Ruby has been successfully installed 🎉
🚧 Common Errors and Solutions
🛑 ruby: command not found Restart Terminal or run the command source ~/.bash_profile.
🛑 brew doctor gives error /usr/local/bin should be at the top of your PATH variable. Check the file.
🛑 Homebrew cannot be installed /usr/bin/ruby or curl may be missing. Reinstall Xcode Command Line Tools.
❓ Frequently Asked Questions (FAQ)
1. Why are we editing the PATH variable?
macOS system Ruby is outdated. PATH editing prioritizes the newly installed Homebrew Ruby.
2. Can Ruby be installed without Homebrew?
Yes, RVM or rbenv can be used; but Homebrew is the easiest method for macOS.
3. Why are Xcode Command Line Tools needed?
Ruby's gem packages need compilation tools. These tools are available in the Xcode package.
4. Can I work with Ruby outside of the terminal?
Yes, you can also work in IDEs like VS Code or RubyMine. The terminal is only required for installation.
5. How to install Rails after Ruby?
To install the Rails framework:
gem install rails
🎯 Result
You now have a development environment running with the latest version of Ruby on your macOS device. Thanks to Homebrew, it is very easy to manage, update and uninstall Ruby.
💡 Try testing your Ruby apps by deploying them on the GenixNode platform now!

