How Does Homebrew Add Things to My Environment?

1

3

OS X 10.11.5. I'm new to OS X and Ruby. I used homebrew to install chruby and ruby-install, then used these to install Ruby and Rails. Later I installed RubyMine. I like it, but it does not support chruby. I want to uninstall chruby and ruby-install and use RVM. On a different iMac I installed rvm and RubyMine and everything works fine. Now I want to clean up my iMac to install rvm.

The main thing I don't understand is how my set output has things like these:

GEM_PATH=/Users/mark/.gem/ruby/2.3.1:/Users/mark/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0
GEM_ROOT=/Users/mark/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0
...
RUBY_ROOT=/Users/mark/.rubies/ruby-2.3.1
RUBY_VERSION=2.3.1
...
chruby_reset () 
{ 
    [[ -z "$RUBY_ROOT" ]] && return;  
    PATH=":$PATH:";
PATH="${PATH//:$RUBY_ROOT\/bin:/:}";
if (( $UID != 0 )); then
    [[ -n "$GEM_HOME" ]] && PATH="${PATH//:$GEM_HOME\/bin:/:}";
    [[ -n "$GEM_ROOT" ]] && PATH="${PATH//:$GEM_ROOT\/bin:/:}";
    GEM_PATH=":$GEM_PATH:";
    [[ -n "$GEM_HOME" ]] && GEM_PATH="${GEM_PATH//:$GEM_HOME:/:}";
    [[ -n "$GEM_ROOT" ]] && GEM_PATH="${GEM_PATH//:$GEM_ROOT:/:}";
    GEM_PATH="${GEM_PATH#:}";
    GEM_PATH="${GEM_PATH%:}";
    unset GEM_ROOT GEM_HOME;
    [[ -z "$GEM_PATH" ]] && unset GEM_PATH;
fi;
PATH="${PATH#:}";
PATH="${PATH%:}";
unset RUBY_ROOT RUBY_ENGINE RUBY_VERSION RUBYOPT;
hash -r
}
...

I've looked in the places man bash says to look, /etc/bashrc, /etc/profile, ~/.bash_profile and ~/.bashrc, but I have not figured out how GEM_PATH gets put in my bash shell.

Mark Jerde

Posted 2016-05-29T04:40:08.057

Reputation: 111

have you tried just grepping for GEM_PATH in your homdir and root if necessary (e.g. grep -Rni 'GEM_PATH' / 2>/dev/null to avoid not-access err msg)? – guessimtoolate – 2016-05-29T20:53:02.590

Answers

0

I know there must be better ways, but I had been unproductive too long. I decided to "rename to uninstall", check everything carefully, then install Homebrew as if it was fresh. I could not rename /usr/local, but I was able to rename everything inside it. Several restarts later, RVM is installed and RubyMine is working! My /usr/local looks like this.

...
drwxr-xr-x  24 mark  admin   816 May 29 16:06 bin/
drwxr-xr-x  92 mark  admin  3128 May 19 18:21 bin_old/
drwxr-xr-x   4 mark  admin   136 May 29 16:06 etc/
drwxr-xr-x   4 mark  admin   136 May 10 15:52 etc_old/
...

Mark Jerde

Posted 2016-05-29T04:40:08.057

Reputation: 111