postmodern / chruby

Changes the current Ruby
MIT License
2.85k stars 190 forks source link

Homebrew ruby appears as system ruby #377

Closed maxim closed 6 years ago

maxim commented 7 years ago

I just started using chruby + ruby-install on my brand new/clean sierra mbp, and I noticed that ruby-install uses homebrew to install rubies. Homebrew places binaries to /usr/local/bin/ and makes it a prioritized path. Chruby then starts seeing /usr/local/bin/ruby as a system ruby, but the real system ruby is /usr/bin/ruby. This is probably due to PATH order, but is there any way to deal with it? It also causes confusion in a sense that 2.3.2 right now is both my "system" ruby and my "2.3.2" ruby, but they have a different set of gems. Or am I doing something wrong?

havenwood commented 7 years ago

You can install ruby-install and chruby with brew but ruby-install doesn't itself use Homebrew to install Rubies. When you install Ruby with Homebrew by default it creates a /usr/local/bin/ruby symlink to your ../Cellar/ruby/x.y.z/bin/ruby binary. So you'll see the brew Ruby instead of system Ruby since brew's /usr/local/bin/ruby symlink in is ahead of system Ruby's /usr/bin/ruby symlink in your PATH.

You can brew unlink ruby to remove the Homebrew symlink for Ruby and brew link ruby to restore it. That will determine what Ruby chruby falls back to when you tell chruby to use system Ruby.

havenwood commented 6 years ago

Closing since this is seemingly brew's intended behavior. Please open a new issue if there are similar issues or proposed features based on this. Thanks!