Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Ruby with Homebrew

I installed Ruby with Homebrew:

brew install ruby

Under "Caveats" it said:

NOTE: By default, gem installed binaries will be placed into:
/usr/local/Cellar/ruby/1.9.3-p194/bin

You may want to add this to your PATH.

What does that mean and how can I add it to my "path"? Assuming it has to do with a bash_profile but new to this.

like image 940
cchiera Avatar asked Sep 05 '12 18:09

cchiera


People also ask

Where does Homebrew install Ruby Mac?

On Mac Intel, you'll see /usr/local/ . You can confirm that Homebrew installed Ruby with brew list . You can see a list of the dependencies installed for Ruby with brew deps --tree --installed .

Where does Homebrew Ruby install gems?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9.

Can Mac run Ruby?

All versions of Ruby on Mac use Homebrew as the foundation of your development setup. The Basic version installs chruby and ruby-install with Homebrew, then installs the latest version of Ruby. This is the minimum required to work with Ruby.


3 Answers

in ~/.bash_profile add the following line

export PATH=/usr/local/Cellar/ruby/1.9.3-p194/bin:$PATH 

When you're done, close your terminal and re-open it. You should be fine.

Alternatively, you can execute the follwing in each open shell instead of closing/re-opening:

source ~/.bash_profile 

Note: I highly recommend installing ruby via rvm or rbenv so you can manage multiple ruby versions and use gemsets.

like image 50
Kyle Avatar answered Sep 18 '22 14:09

Kyle


Add this line to your .profile (or .bash_profile, .bashrc, .zshrc, etc):

export PATH=/usr/local/opt/ruby/bin:$PATH 

This is an up-to-date version of Kyle's answer. As of May 2014, brew info ruby prints:

By default, gem installed executables will be placed into:

  /usr/local/opt/ruby/bin 

You may want to add this to your PATH. After upgrades, you can run

  gem pristine --all --only-executables 

...to restore binstubs for installed gems.

like image 38
pje Avatar answered Sep 17 '22 14:09

pje


Install ruby:

brew install ruby

I'd recommend setting $PATH, $GEM_PATH and $GEM_HOME. For latest Ruby it's:

export PATH=/usr/local/opt/ruby/bin:$PATH
export GEM_HOME=/usr/local/opt/ruby/lib/ruby/gems/2.6.0
export GEM_PATH=/usr/local/opt/ruby/lib/ruby/gems/2.6.0

Put them in something like ~/.bash_profile.

And then to verify:

type -a ruby
> ruby is /usr/local/opt/ruby/bin/ruby
> ...

ruby -v
> ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]

gem list
> *** LOCAL GEMS ***
> 
> did_you_mean (1.3.0)
> minitest (5.11.3)
> ...
like image 45
Paweł Gościcki Avatar answered Sep 17 '22 14:09

Paweł Gościcki