It’s relatively easy to set up your Ruby project in Gitpod.

Ruby Versions

As of this writing, Gitpod comes with Ruby 3.1 pre-installed in the gitpod/workspace-full.

To use a different Ruby version, you can change the base image to one of the following:

These images (see on dockerhub) are automatically updated every week with the latest ruby patch versions.

To use a fixed version, you may use a custom Dockerfile.

FROM gitpod/workspace-full
USER gitpod

# Install Ruby version 2.7.6 and set it as default
RUN _ruby_version=ruby-2.7.6 \
    && printf "rvm_gems_path=/home/gitpod/.rvm\n" > ~/.rvmrc \
    && bash -lc "rvm reinstall ${_ruby_version} && \
                 rvm use ${_ruby_version} --default" \
    && printf "rvm_gems_path=/workspace/.rvm" > ~/.rvmrc \
    && printf "{ rvm use \$(rvm current); } >/dev/null 2>&1\n" >> "$HOME/.bashrc.d/70-ruby"

💡 Explanation: Gitpod initially sets up RVM in /home/gitpod/.rvm, but then later switches the RVM configuration directory to /workspace/.rvm, so that any user-made changes (like installing new gems) are persisted within a Gitpod workspace. However, during the Dockerfile build, the /workspace directory doesn’t exist yet, so we temporarily reset RVM’s configuration directory to /home/gitpod/.rvm.

Example Repositories

Here are a few Ruby example projects that are already automated with Gitpod:

RepositoryDescriptionTry it
Ruby on Rails templateRuby on Rails template with a PostgreSQL database
ForemThe platform that powers dev.to
GitLabThe open source end-to-end software development platform

VS Code Extensions

Here are a few useful extensions that you’ll likely want to install in your Ruby project.

Ruby Test Explorer

With the Ruby test explorer, you can run unit tests from within the Gitpod UI. To add this extension to your repository, simply add these lines to your .gitpod.yml configuration file:

vscode:
    extensions:
        - connorshea.vscode-ruby-test-adapter@0.9.0
        - hbenl.vscode-test-explorer@2.21.1

Ruby On Rails

So, you want to write your cool new Ruby On Rails application in Gitpod? Well, here is an idea of how to do it. Please take a look at our minimal Rails example running in Gitpod:

FAQs

How to avoid the need to run “bundle install” each time I restart my workspace?

To avoid running bundle install each time you restart your workspace in Gitpod, try changing your .gitpod.yml file configuration. Instead of using init, use a before task, as it will be re-run each time the workspace is restarted.

Here’s an example:

tasks:
    - before: bundle install

For more information on tasks, refer to the Gitpod docs on tasks.

Note: When a workspace is deactivated, only the workspace directory is saved and restored. Therefore, if bundle install creates files in various places in the file system, they may not be retained after a restart.