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.
$ ruby -v
/usr/bin/env: 'ruby': No such file or directory
# or
bash: ruby: command not foundCommon 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.
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
ruby -v && bundle -vPrefer setup-ruby on GitHub Actions
setup-ruby provisions Ruby and puts it on PATH directly, sidestepping rbenv init entirely.
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: trueHow 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.