Using Ruby
ServBay provides Ruby developers with a highly efficient and flexible development environment on macOS. With ServBay’s package management system, you can easily install and manage multiple Ruby versions in parallel. The powerful .servbay.config file allows you to specify the required Ruby version for each project, streamlining your workflow and ensuring consistent environments.
Overview
Introduction to Ruby
Ruby is a dynamic, open-source, object-oriented programming language renowned for its simple and elegant syntax, and its focus on developer productivity. Created in the mid-1990s by Japanese computer scientist Yukihiro "Matz" Matsumoto, Ruby’s philosophy is to “make programming fun”. Influenced by languages like Perl, Smalltalk, Eiffel, Ada, and Lisp, Ruby emphasizes code readability and simplicity.
In Ruby, everything is an object. The language supports multiple programming paradigms, including object-oriented, procedural, and functional programming. Ruby’s worldwide popularity surged after David Heinemeier Hansson (DHH) released the Ruby on Rails web framework in 2004, which dramatically increased the efficiency of web application development. Today, Ruby is widely used in web development (Rails, Sinatra), scripting, automation, prototyping, and more. Its ecosystem is powered by RubyGems (the package manager) and Bundler (the dependency manager).
ServBay’s Ruby Support
ServBay manages different Ruby interpreter versions as independent packages. This brings you several core benefits:
- Parallel Multiple Versions: Install multiple Ruby versions at the same time (e.g., Ruby 2.7, 3.0, 3.3, 3.4) without worrying about version conflicts.
- Project-level Version Control: Precisely specify the Ruby version your project depends on by using ServBay’s unique
.servbay.configfile. - Simplified Management: View, install, and uninstall any Ruby version easily through ServBay’s intuitive graphical interface.
- Integrated Gem Management: After installing Ruby, you can directly use the
gemcommand to manage RubyGems.
This is essential for developers who need to maintain legacy projects using different Ruby versions, develop new projects (like Ruby on Rails apps), or run specific Ruby tools.
Accessing Ruby Packages
- Open the ServBay application.
- In the left navigation bar, click
Packages. - On the
Packagespage, scroll down or selectLanguages->Rubyfrom the sidebar. - The right pane will show a list of all available Ruby packages.

Installing Ruby
The package list clearly displays the status of each Ruby version:
- Package Name: The name of the package, such as
Ruby 3.3. - Version: The specific version number of the package.
- Status: Displays either
InstalledorNot Installed. - Control: Offers action buttons.
To install a Ruby version that is not yet installed (for example, Ruby 3.3):
- Locate the desired version in the list.
- Ensure its status shows
Not Installed. - Click the Download/Install icon (usually a downward arrow) at the far right of that row.
- ServBay will start downloading and installing the selected Ruby version. The process may take some time.
- Once the installation completes, the status will change to
Installed, and the control icon will become the Uninstall (trash bin) icon.
Managing Installed Ruby Versions
- View Installed Versions: The
Installedstatus clearly marks which Ruby versions are currently present in your environment. - Uninstall Ruby: If you no longer need a particular Ruby version, simply click its Uninstall (trash bin) icon and confirm the action to remove it from your system.
Using Installed Ruby
After Ruby is installed, ServBay adds it to the environment variables it manages. When you activate the ServBay environment in your terminal, you can immediately use the ruby and gem commands.
Common Commands Examples:
Check the Active Ruby Version: Open your terminal and run:
bashruby -v1This will show the Ruby version currently active in your terminal session. The version may be affected by global settings or a project-specific
.servbay.configfile.Check RubyGems Version:
bashgem -v1Install a Gem Package: For example, install the popular static site generator Jekyll:
bashgem install jekyll1Or install the Ruby on Rails framework:
bashgem install rails1Run a Ruby Script: Create a file named
hello.rbwith the following content:ruby#!/usr/bin/env ruby puts "Hello from Ruby in ServBay!"1
2Run it in your terminal:
bashruby hello.rb1
Project-level Version Management: .servbay.config
One of ServBay’s core strengths is its support for project-level environment configuration. By placing a .servbay.config file at the root of your project, you can lock the required Ruby version for that specific project.
Advantages:
- Multi-language Management: Manage versions of Ruby, PHP, Node.js, Python, Go, Java, .NET, and more in a single file.
- Ensured Consistency: Make sure all team members or deployment environments use exactly the same Ruby version.
- Auto-switching: When you
cdinto a directory containing.servbay.config, ServBay will automatically recognize and apply theRUBY_VERSIONdefined in that file.
Example Configuration:
Create a .servbay.config file in your Ruby project’s root directory and add a RUBY_VERSION variable specifying the desired major version (e.g., 2.7, 3.3). ServBay will automatically select the latest installed revision from that major version series.
ini
# .servbay.config
# Specify the major Ruby version for this project (e.g., 3.3)
# ServBay will automatically use the latest installed 3.3.x version
RUBY_VERSION=3.3
# You can also specify other language versions and settings
NODE_VERSION=18
# ... other configurations ...1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
When you open a terminal in this directory with the ServBay environment activated, running ruby -v will display the Ruby version you designated in .servbay.config (or the latest installed version in that series).
Simple Usage Example
Let’s create a simple project to demonstrate how to use .servbay.config:
Create the Project Directory:
bashmkdir my-ruby-project cd my-ruby-project1
2Create
.servbay.config: In themy-ruby-projectdirectory, create a.servbay.configfile with the following content:iniRUBY_VERSION=2.7 # Assuming you have Ruby 2.7.x installed1(Ensure that you have installed Ruby 2.7 in ServBay)
Create a Ruby Script: Create an
app.rbfile:ruby#!/usr/bin/env ruby puts "Project is using Ruby version: #{RUBY_VERSION}"1
2Activate and Verify: (Make sure your terminal has the ServBay environment activated) In the
my-ruby-projectdirectory, run:bashruby -v1The output should show you the installed Ruby 2.7.x version.
Run the Script:
bashruby app.rb1The output should be:
Project is using Ruby version: 2.7.x(where x is the specific revision you have installed).Install Project Dependencies (Example): If your project uses Bundler (common for Rails projects), you can run:
bash# If bundler is not installed # gem install bundler bundle install1
2
3Bundler will install dependencies according to the
Gemfilein your project and the currently active Ruby version (2.7.x).
Now, if you have another project that needs Ruby 3.4, just set RUBY_VERSION=3.4 in that project’s .servbay.config file. ServBay will switch your Ruby environment automatically when you change directories.
Integrating with Web Servers (Rails, Sinatra, etc.)
For web apps built with Ruby on Rails, Sinatra, or other frameworks, it’s common to use application servers like Puma, Unicorn, or Thin. You can:
- Create a Website entry for your app in ServBay.
- Configure ServBay’s web server (Nginx, Caddy, Apache) as a reverse proxy, forwarding requests from a specific domain to your Ruby app server’s listening port (such as
http://localhost:3000or the Unix socket used by Puma/Unicorn). For details, see the guide on using a reverse proxy for your web apps.
This setup allows you to take full advantage of ServBay’s domain management, automatic HTTPS (if configured), and provides a unified access point for your Ruby application.
Conclusion
ServBay greatly simplifies Ruby development on macOS. Through its user-friendly package management interface and robust .servbay.config project-level version control, you can easily manage multiple Ruby versions and Gems, ensuring each project has a consistent and isolated environment for more efficient and reliable Ruby development.
