Ruby Installation & Setup
Get Ruby up and running on your system with the best practices for version management and development environment setup.
System Requirements
Minimum Requirements
- Operating System: Windows 10+, macOS 10.14+, or Linux (Ubuntu 18.04+, CentOS 7+)
- Memory: 1GB RAM minimum (2GB+ recommended for development)
- Disk Space: 200MB for Ruby installation + 500MB for development tools
- Internet: Required for downloading Ruby and gems
Recommended Setup
- Memory: 4GB+ RAM for comfortable development
- Storage: SSD recommended for faster gem installation
- Ruby Version: Ruby 3.2+ (latest stable)
- Version Manager: rbenv (recommended) or RVM
Installation Methods
macOS Installation
Method 1: Using Homebrew (Recommended)
Method 2: Using rbenv (Version Management)
Linux Installation
Ubuntu/Debian
CentOS/RHEL/Fedora
Windows Installation
Method 1: RubyInstaller (Recommended)
- Visit rubyinstaller.org
- Download Ruby+Devkit 3.2.x (x64) installer
- Run the installer and follow the setup wizard
- Choose "MSYS2 and MINGW development toolchain" when prompted
- Open Command Prompt and verify:
ruby --version
Method 2: Using Chocolatey
Verify Installation & PATH
If you use rbenv, ensure your shell loads it (e.g., add eval "$(rbenv init -)" to your shell rc file and restart the terminal).
Editor & Tooling Recommendations
- Install a modern editor (e.g., VS Code or RubyMine) and enable Ruby LSP for autocomplete and navigation.
- Install RuboCop for code style and linting; run
rubocop -ato auto-fix common issues. - Use a terminal with persistent history; consider setting up a project folder for your exercises.
Troubleshooting (Common Issues)
- OpenSSL errors (macOS): Install OpenSSL with Homebrew and ensure it’s linked as needed.
- Build tools (Linux): Install build-essential, libssl-dev, and related headers for compiling Ruby and gems.
- Windows devkit: When using RubyInstaller, select “MSYS2 and MINGW toolchain” to avoid native gem build failures.
- WSL (Windows): For a Linux-like environment, use WSL and follow Linux install steps inside your distro.
Version Management
Why Use a Version Manager?
Version managers allow you to install and switch between multiple Ruby versions, which is essential for working on different projects that may require different Ruby versions.
rbenv (Recommended)
rbenv is a lightweight Ruby version management tool that's simple, fast, and doesn't interfere with your shell.
Installation & Usage
RVM (Ruby Version Manager)
RVM is a comprehensive Ruby environment management tool that provides more features but is heavier than rbenv.
Installation & Usage
Verification & Next Steps
Verify Your Installation
If you see version numbers and "Hello, Ruby!" output, your installation is successful!
Next Steps
- Install Bundler:
gem install bundler - Learn IRB: Start the Interactive Ruby shell with
irb - Write Your First Program: Create a simple Ruby script
- Explore Ruby Documentation: Learn how to find help and documentation
Common Issues & Troubleshooting
"Command not found: ruby"
Cause: Ruby is not in your system PATH.
Solution: Restart your terminal, or add Ruby to your PATH manually. If using rbenv, make sure you've run rbenv init.
"Permission denied" errors
Cause: Trying to install gems system-wide without proper permissions.
Solution: Use a version manager (rbenv/RVM) or install gems with --user-install flag.
Outdated Ruby version
Cause: System package manager installed an older Ruby version.
Solution: Use a version manager to install the latest Ruby version, or update your system packages.