Skip to content
Latchkey

ruby/setup-ruby

Install Ruby and, with one input, install and cache your gems via Bundler.

Community actionCategory: Language & Toolchain SetupLatest v1View on GitHub

What it does

ruby/setup-ruby installs a Ruby version (faster than the runner default) and, when bundler-cache: true, runs bundle install and caches the installed gems keyed on Gemfile.lock.

It reads the version from .ruby-version or .tool-versions automatically when present.

Usage

workflow (.yml)
steps:
  - uses: actions/checkout@v4
  - uses: ruby/setup-ruby@v1
    with:
      ruby-version: '3.3'
      bundler-cache: true
  - run: bundle exec rake

Inputs

InputDescriptionDefaultRequired
ruby-versionRuby version, e.g. 3.3. Reads .ruby-version if omitted..ruby-versionNo
bundler-cacheRun bundle install and cache the gems.falseNo
working-directoryDirectory containing the Gemfile..No

Outputs

OutputDescription
ruby-prefixInstall path of the Ruby.
ruby-platformThe platform of the installed Ruby.

Notes

bundler-cache: true replaces a separate bundle install plus actions/cache step.

Common errors

  • A slow job re-running bundle install every time usually has bundler-cache unset. Set it to true.
  • A Gemfile in a subfolder needs working-directory set so caching keys on the right lockfile.

Security and pinning

  • Pin to a commit SHA (the @v1 tag moves).

Frequently asked questions

Do I need a separate cache step for gems?
No. Set bundler-cache: true and setup-ruby runs bundle install and caches the gems for you.

References

Running ruby/setup-ruby? Run it on Latchkey managed runners - self-healing and caching included. Start free → 30-day trial · No credit card