To install Ruby on Rails on Mac OS Lion, you’ll need to follow a few steps.
Click the Apple menu in the top-left corner of your screen.
Select “About This Mac” to see your current OS version. If it’s Lion, you’ll see version 10.7.
Open the Terminal (you can find it in the “Utilities” folder within the “Applications” folder).
Run the following command to install Xcode Command Line Tools if you haven’t already:
xcode-select --install
Homebrew is a package manager for macOS that makes it easier to install software. You can install it by running this command in the Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Rbenv is a tool for managing Ruby versions, and Ruby-build is a plugin for rbenv that simplifies the installation of different Ruby versions. Install them via Homebrew:
brew install rbenv brew install ruby-build
Add rbenv to bash so that it loads every time you open a Terminal:
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc source ~/.zshrc
You might need to replace `~/.zshrc` with `~/.bashrc` if you are not using the Zsh shell.
Check which versions of Ruby are available:
rbenv install -l
Choose a Ruby version (e.g., 2.7.4) and install it:
rbenv install 2.7.4
Set the global Ruby version:
rbenv global 2.7.4
Use the gem package manager (which comes with Ruby) to install Rails:
gem install rails
To ensure that Rails has been installed successfully, run:
rails -v
This command should display the installed Rails version.