Either the indentation got messed up or you wanted to move line 143-148 into the rbenv_or_rvm function... COMMAND_PREFIX needs to be declared as a global if you are trying to move that code into rbenv_or_rvm. but works for me after changing that :)