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
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 installedCommon 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
| Flag | What it does |
|---|---|
| -s / --skip-existing | Skip if already installed |
| -f / --force | Reinstall over an existing version |
| -l / --list | List installable versions |
| init - | Emit shell setup (eval this) |
| rehash | Regenerate shims after new gems with binaries |