rbenv command not found on Mac OS

7.4k Views Asked by At

We are trying to run rbenv on El-Capitan 10.11.6. When we try to run rbenv command in the terminal we got the following error message:

command not found

We googled how to solve that issue and one possible solution is to add the "rbenv" to the system PATH, we followed the steps stated in this link. When we run the "$PATH" to check whether or not the rbenv path was added properly into the system PATH, we got the the same result:

command not found

The result of "$PATH" command is:

qwe-Mac-mini:~ amrbakri$ rbenv

-bash: rbenv: command not found
qwe-Mac-mini:~ asd$ echo $PATH    

/Users/asd/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin

Can you please tell me how to add the path of rbenv properly? And what did I do wrong in the previous steps so that I can fix it.

2

There are 2 best solutions below

0
On

I following the instructions about "bash" command, then do the "eval" operation.

I'm in MacOS 11.2.3, in your .bash_profile, add the two lines.

export PATH="$HOME/.rbenv/bin:$PATH"#this is the required step for my mac

eval "$(rbenv init -)"

refer: https://github.com/rbenv/rbenv#homebrew-on-mac-os-x

0
On

rbenv isn't a normal command if you've installed it correctly:

$ type rbenv
rbenv is a function
. . .

According to Homebrew on Mac OS X:

You'll only ever have to run rbenv init once.

That's a bit misleading because the result of running the command is:

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

So you need to manually add eval "$(rbenv init -)" to some file that bash will source on startup. For most people ~/.bash_profile is the right place.

I notice the commands you listed seem to be run from two different users: amrbakri and asd. Combined with the question's use of "we", I wonder if there might be a problem with the environment being set correctly for one user, but not the other. Can you try using just one user?

If you are running from a non-interactive shell (such as in a crontab), you might need to add eval "$(rbenv init -)" to the startup script.