ruby/setup-ruby@v1

Download a prebuilt Ruby and add it to the PATH in 5 seconds

At a glance

Latest major
v1
Repository
ruby/setup-ruby
Inputs
9 (0 required)
Outputs
1
Runs using
node24
License
MIT
Last checked

Inputs and outputs come straight from the action's official action.yml. See our editorial standards.

Usage

- uses: ruby/setup-ruby@v1

Inputs

NameRequiredDefaultDescription
ruby-versionNodefaultEngine and version to use, see the syntax in the README. Reads from .ruby-version, .tool-versions or mise.toml if unset.
rubygemsNononeThe version of RubyGems to use. Either 'default' (the default), 'latest', or a version number (e.g., 3.3.5). For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used. For 'latest', `gem update --system` is run to update to the latest compatible RubyGems version. Ruby head/master builds will not be updated. Similarly, if a version number is given, `gem update --system <version>` is run to update to that version of RubyGems, as long as that version is newer than the one provided by default.
bundlerNononeThe version of Bundler to install. Either 'Gemfile.lock' (the default), 'default', 'latest', 'none', or a version number (e.g., 1, 2, 2.1, 2.1.4). For 'Gemfile.lock', the version of the BUNDLED WITH section from the Gemfile.lock if it exists. If the file or section does not exist then the same as 'default'. For 'default', if the Ruby ships with Bundler 2.2+ as a default gem, that version is used, otherwise the same as 'latest'. For 'latest', the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.3, Bundler 1 on Ruby < 2.3). For 'none', nothing is done.
bundler-cacheNofalseRun "bundle install", and cache the result automatically. Either true or false.
working-directoryNononeThe working directory to use for resolving paths for .ruby-version, .tool-versions, mise.toml and Gemfile.lock.
cache-versionNononeArbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need to invalidate the cache.
self-hostedNononeConsider the runner as a self-hosted runner, which means not using prebuilt Ruby binaries which only work on GitHub-hosted runners or self-hosted runners with a very similar image to the ones used by GitHub runners. The default is to detect this automatically based on the OS, OS version and architecture.
windows-toolchainNononeThis input allows to override the default toolchain setup on Windows. The default setting ('default') installs a toolchain based on the selected Ruby. Specifically, it installs MSYS2 if not already there and installs mingw/ucrt/mswin build tools and packages. It also sets environment variables using 'ridk' or 'vcvars64.bat' based on the selected Ruby. At present, the only other setting than 'default' is 'none', which only adds Ruby to PATH. No build tools or packages are installed, nor are any ENV setting changed to activate them.
tokenNo${{ github.server_url == 'https://github.com' && github.token || '' }}Used to authenticate with GitHub when downloading Ruby release assets. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.

Outputs

NameDescription
ruby-prefixThe prefix of the installed ruby

Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.

Examples

Ruby with bundler cache

Install Ruby and run `bundle install` with caching in one step.

name: Example
on:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: Setup Ruby, JRuby and TruffleRuby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.3
          bundler-cache: true
      - run: bundle exec rake

Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.

Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.