Skip to content
Latchkey

rbenv install: Usage, Options & Common CI Errors

rbenv install compiles and installs a Ruby version using the ruby-build plugin.

rbenv installs Ruby versions from source via ruby-build, so it shares pyenv's pattern: it needs build dependencies and its shims on PATH. The same two failure classes apply.

What it does

rbenv install <version> compiles a Ruby version into ~/.rbenv/versions using the ruby-build plugin. rbenv local writes .ruby-version to pin a project. As with pyenv, ruby resolves through ~/.rbenv/shims, which must be on PATH with rbenv init evaluated.

Common usage

Terminal
apt-get install -y build-essential libssl-dev libreadline-dev zlib1g-dev libyaml-dev
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
rbenv install 3.3.4
rbenv local 3.3.4
rbenv install -s 3.3.4                            # skip if installed

Common errors in CI

"BUILD FAILED" from ruby-build usually means missing -dev libraries - libssl-dev, libreadline-dev, zlib1g-dev, and (for newer Ruby) libyaml-dev for psych. "rbenv: version \"3.3.4\" is not installed" means .ruby-version names an uninstalled version. The shim trap mirrors pyenv: without eval "$(rbenv init -)" and the shims on PATH, ruby runs the system version. After bundle install adds binstubs, run rbenv rehash so new shims register.

Options

FlagWhat it does
-s / --skip-existingSkip if already installed
-f / --forceReinstall over an existing version
-l / --listList installable versions
init -Emit shell setup (eval this)
rehashRegenerate shims after new gems with binaries

Using this in CI

A runner shell is not a login shell. It does not read your dotfiles, it usually has no TTY, and by default it does not stop on the first error, so a failing command in the middle of a multi-line run block can leave the job green.

.github/workflows/ci.yml
# make the shell behave the way you assume it does
- name: Build
  shell: bash
  run: |
    set -euo pipefail    # exit on error, undefined vars, and pipeline failures
    ./do-the-thing | tee out.log

Frequently asked questions

rbenv install: Usage, Options & Common CI Errors?
rbenv installs Ruby versions from source via ruby-build, so it shares pyenv's pattern: it needs build dependencies and its shims on PATH. The same two failure classes apply.
What it does?
rbenv install <version> compiles a Ruby version into ~/.rbenv/versions using the ruby-build plugin. rbenv local writes .ruby-version to pin a project. As with pyenv, ruby resolves through ~/.rbenv/shims, which must be on PATH with rbenv init evaluated.
Common errors in CI?
"BUILD FAILED" from ruby-build usually means missing -dev libraries - libssl-dev, libreadline-dev, zlib1g-dev, and (for newer Ruby) libyaml-dev for psych. "rbenv: version \"3.3.4\" is not installed" means .ruby-version names an uninstalled version.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card