Pregunta

I'm using Homebrew for OS X and have non-default ruby and rails installations on my system. I was performing a reinstall of those tools and found a curious problem.

When I run rails on my system it seems to be invoking the default version:

$ rails
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

However, which rails shows the correct path:

$ which rails
/usr/local/Cellar/ruby/2.1.2/bin/rails

Likewise, which -a rails shows both paths:

$ which -a rails
/usr/local/Cellar/ruby/2.1.2/bin/rails
/usr/bin/rails

The unusual part being that I believe the /usr/local/Cellar/ruby/2.1.2/bin/rails should be executed instead of the /usr/bin/rails version. Invoking /usr/local/Cellar/ruby/2.1.2/bin/rails --version directly works:

$ /usr/local/Cellar/ruby/2.1.2/bin/rails --version
Rails 4.1.1

Why doesn't invoking rails run the version at /usr/local/Cellar/ruby/2.1.2/bin/rails? Is there something I'm missing? Here's my PATH variable for reference: /usr/local/Cellar/ruby/2.1.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

¿Fue útil?

Solución

Try brew doctor if it doesn't fix the issue, edit the /etc/paths to look like

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

As described in here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top