Skip to content
Latchkey

rbenv "ruby: command not found" in CI

rbenv works by putting a shims directory ahead of the real Ruby on PATH and initializing it per shell. In a non-interactive CI shell that never runs rbenv init, the shims are absent and ruby (or bundle) is not found at all.

What this error means

A step fails with "ruby: command not found" or "bundle: command not found" even though rbenv and a Ruby version are installed. The shims path is missing from PATH in the CI shell.

bundler
$ ruby -v
/usr/bin/env: 'ruby': No such file or directory
# or
bash: ruby: command not found

Common causes

rbenv init never ran in the CI shell

CI shells are non-login/non-interactive and do not source the profile that runs rbenv init, so the shims directory is never prepended to PATH.

The shims directory is not on PATH

Even with rbenv present, ~/.rbenv/shims is not exported in the job environment, so the ruby shim cannot be found.

How to fix it

Initialize rbenv in the job

Add rbenv to PATH and run its init so shims resolve for every command.

Terminal
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
ruby -v && bundle -v

Prefer setup-ruby on GitHub Actions

setup-ruby provisions Ruby and puts it on PATH directly, sidestepping rbenv init entirely.

.github/workflows/ci.yml
- uses: ruby/setup-ruby@v1
  with:
    ruby-version: '3.3'
    bundler-cache: true

How to prevent it

  • Add rbenv init (or export the shims path) at the top of CI shell steps.
  • Prefer setup-ruby on GitHub Actions so PATH is configured for you.
  • Avoid relying on interactive shell profiles in non-interactive CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →