Setting up a Ruby development environment Stay organized with collections Save and categorize content based on your preferences.
This tutorial shows how to prepare your local machine forRuby development, including developing Ruby apps that run on Google Cloud. Followthis tutorial to install Ruby and relevant tools.
ReadQuickstart for Ruby and Google Cloud to get anoverview of Ruby and learn ways to run Ruby apps on Google Cloud.
Objectives
- Install Ruby.
- Install Bundler.
- Install an editor (optional).
- Install the Google Cloud CLI.
- Install the Cloud Client Libraries for Ruby.
- Set up authentication.
Install Ruby
Ruby's installation instructions vary by operating system. Follow the guide forthe operating system you're using on your local development machine. Thistutorial applies to stable and non-end-of-life (EOL) Ruby versions listed onRuby-lang.
macOS
We recommend usingrbenv to manage your Ruby installations on macOS.rbenv manages multiple Ruby versioninstallations on your machine and a rbenv pluginnamedruby-build adds support torbenv to install a specified version of Ruby.
While macOS includes a version of Ruby by default, it's best to perform aseparate install of the latest versions of Ruby to stay up-to-date and avoidconflicts with the operating system's use of its default version.
- InstallXCode.
InstallXCode's command line tools by using the following command in a terminal:
xcode-select--installInstall
homebrewby following the instructions on thehomebrew homepage.Install
rbenvby usinghomebrew, following the instructions in therbenv readme.The homebrew installation includes theruby-buildplugin.
Learn more aboutusing rbenv andruby-build to install different versions of Ruby.
Linux
We recommend usingrbenv to manage your Ruby installations on Linux distributions.rbenv manages multiple Ruby versioninstallations on your machine and arbenv plugin namedruby-build adds support torbenv to install a specified version of Ruby.
Install
rbenvon your Linux distribution by using therbenvreadme.Install the
ruby-buildplugin forrbenvby using the instructions in theruby-buildreadme.
Learn more aboutusingrbenv andruby-build to install different versions of Ruby.
Windows
For Windows, we recommend one of the following:
Install Bundler
Bundler is a Ruby gem that manages project gem dependencies defined in a file namedGemfile. The Ruby samples in Google Cloud's documentation useGemfile files to specify required gems and versions.
Install Bundler.
gem install bundler
Install
gemdependencies defined in theGemfile.bundle install
Run your Ruby project only using gems defined in your
Gemfile.bundle exec ruby app.rb
Learn more about creating aGemfile by readingBundler documentation.
Install an editor
Popular editors (in no particular order) used to develop Ruby apps include, butaren't limited to:
- Sublime Text by Jon Skinner
- Atom by GitHub
- RubyMine by JetBrains
- Vim by Vim the editor
These editors (sometimes with the help of plugins) give you everything fromsyntax highlighting, intelli-sense, and code completion to fully integrateddebugging capabilities, maximizing your Ruby development efficacy.
Install the gcloud CLI
Thegcloud CLI is a set of tools for Google Cloud. It containsgcloud andbq, whichyou can use to access Compute Engine, Cloud Storage, BigQuery, andother products and services from the command line. You can run these toolsinteractively or in your automated scripts.
bundle exec ruby app.rb -p 8080:gcloudappdeployLearn how todeploy a Ruby on Rails app to the App Engine flexible environment.
Install the Cloud Client Library for Ruby
TheCloud Client Library for Ruby is the idiomatic way for Ruby developers to integrate with Google Cloudservices. You can install the package for an individual API, such asCloud Storage for example:
geminstallgoogle-cloud-storageYou can also use Bundler and add the gem to yourGemfile dependencies, forexample:
bundleaddgoogle-cloud-storageSet up authentication
To use the Cloud Client Libraries in a local development environment, setup Application Default Credentials.
If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, seeAuthenticate for using client libraries.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.