Can't seem to use ruby from rbenv
Resolved 💬 6 comments Opened Nov 4, 2025 by samsonjs Closed Mar 29, 2026
What version of Codex is running?
codex-cli 0.53.0
What subscription do you have?
ChatGPT Pro
Which model were you using?
gpt-5-codex high
What platform is your computer?
Darwin 25.1.0 arm64 arm
What issue are you seeing?
I use zsh and rbenv. Even when asked to use eval "$(rbenv init -)" codex can't use ruby installed via rbenv and it can only find the system ruby.
What steps can reproduce the bug?
Uploaded thread: 019a502a-9908-7983-81df-15125da14a0d
What is the expected behavior?
It should inherit my shell's environment or at least be able to use rbenv somehow.
Additional information
_No response_
6 Comments
My workaround was to add the following line to my
~/.profile:export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"@icaroryan same works for ASDF
That doesn't seem to work for me on macOS 26.1. My default shell is zsh.
in my case, add to below line to
~/.zprofileis fixed issue.eval "$(/opt/homebrew/bin/rbenv init - --no-rehash zsh)"I'm trying to get codex to execute the right version of ruby selected by rbenv. Mangling my user profile files didn't solve this for me because macOS includes a very old version of ruby in
/usr/bin. You can't rename it and you can't move it.For some reason, codex appears to re-sort the PATH variable which includes moving
/usr/binahead of anything specified in~/.bash_profile.Bash shell:
<img width="629" height="665" alt="Image" src="https://github.com/user-attachments/assets/428a45fb-9b7b-4b8d-b9b9-adb602427b49" />
Codex:
<img width="629" height="665" alt="Image" src="https://github.com/user-attachments/assets/acd64f0e-a539-4ad1-bec3-2c720edb3be9" />
However, I noticed that
/usr/local/binis the first thing on Codex's reshuffled PATH - the workaround for me was to symlink the rbenv shim to/usr/local/bin:<img width="629" height="665" alt="Image" src="https://github.com/user-attachments/assets/08a97560-aa20-4df9-9a6e-1b92a5b9791e" />
With any luck, in a year I'll forget this symlink exists or why it was made and I'll spend a couple of hours trying to debug why on earth something keeps using some crazy rbenv version of ruby instead of the one I want.
Working fine for me now!