11

When I type in which ruby it always returns ruby: aliased to bundled_ruby

When I try which bundled_ruby it returns:

bundled_ruby () {
    _run-with-bundler ruby $@
}

Then I try which _run-with-bundler and it returns:

_run-with-bundler () {
    if _bundler-installed && _within-bundled-project
    then
        bundle exec $@
    else
        $@
    fi
}

Where did all this come from and how do I get my which ruby to work again?

I am using OSX (v10.8.2), brew, rbenv, ruby-build, zsh

Coderama
  • 11,050
  • 12
  • 44
  • 58

2 Answers2

22

It can come from the bundler plugin of oh-my-zsh.

It uses magic to avoid typing bundle exec before the following commands: annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma

You can disable this magic for some commands by defining the UNBUNDLED_COMMANDS environment variable in your ~/.zshrc before loading oh-my-zsh plugins (See oh-my-zsh pull request #2195).

export UNBUNDLED_COMMANDS=ruby
# for a list of commands
export UNBUNDLED_COMMANDS=(ruby irb rake)

Or you can simply remove the bundler plugin from you oh-my-zsh plugins.

cbliard
  • 7,051
  • 5
  • 41
  • 47
  • Quite helpful, I also like that you note where it __might__ come from and not giving a definitive answer as the OP has provided too few information about his environment. Thanks a lot for the help. – Alexander Popov Feb 05 '14 at 09:04
  • 1
    My buddy had this issue on his Mac and my first idea was to look on Stack Overflow, which led me to your answer, which points to a pull request that I wrote and solved the problem. Just thought I'd share that :) – martini-bonanza Feb 06 '14 at 13:18
  • In fact I had the same issue and looked on Stack Overflow too. The proposed answer did not apply to me because I am using `rvm` and not `rbenv`. But it learned me where to search and I found that the zsh bundler plugin was the culprit. By looking at the source code, I saw the `UNBUNDLED_COMMANDS` variable and found your pull request. Once I fixed my problem I added this answer. Thanks for your work :) – cbliard Feb 07 '14 at 08:47
6

This is part of rbenv "magic" to handle several ruby versions with several gem versions. Have a look at ~/.rbenv/shims/ruby, IIRC the script is defined there.

If you want to disable this, just unalias ruby: this deletes the generated alias.

ckruse
  • 9,642
  • 1
  • 25
  • 25