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

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →