You need to edit your PATH
environment variable to look in /usr/local/bin
before /usr/bin
.
See this answer for details.
Simplest is to edit/create ~/.profile
with the line:
export PATH=/usr/local/bin:$PATH
which adds that directory to be the first it looks in. (And then either create a new shell, or source ~/.profile
to re-run the commands in it.)
Edit: If /usr/local/sbin
(the first item in your PATH
) has a symlink for ruby
pointing to /usr/bin/ruby
, you should either remove this file, or create a new symlink, e.g.
$ cd /usr/local/sbin
$ sudo rm ruby
$ sudo ln -s /usr/local/bin/ruby
$ ls -l ruby
lrwxr-xr-x 1 root root 19 Mar 18 09:01 ruby -> /usr/local/bin/ruby