jdrols
jdrols

Reputation: 33

"rails s" using Ruby 1.8.7 instead of Ruby 1.9.3 (OS X 10.7.2)

Odd problem, trying to figure out what is going on here with my fresh install.

I installed Ruby 1.9.3 using homebrew. I installed Rails 3.2.0 using ruby gems. I then created a test application with rails new test_app to make sure everything looked okay in the test environment. Somehow, the rails environment is using 1.8.7 instead of 1.9.3.

When doing a ruby -v, I get this:

overcast:test_app joe$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

But when running rails s I get this:

overcast:test_app joe$ rails s
=> Booting WEBrick
=> Rails 3.2.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-21 23:21:35] INFO  WEBrick 1.3.1
[2012-01-21 23:21:35] INFO  ruby 1.8.7 (2010-01-10) [universal-darwin11.0]

And, obviously, when looking at the rails environment webpage at localhost:3000 I am showing 1.8.7 instead of 1.9.3. I've edited /etc/paths to have /usr/local/bin at the top based on some answers I've found here, but it doesn't seem to make a difference.

Any help would be greatly appreciated!

Addendum: The same situation happens when installing and attempting to use Ruby through RVM.

Upvotes: 3

Views: 1933

Answers (5)

some_other_guy
some_other_guy

Reputation: 3404

sudo update-alternatives --config gem

and select your verison!

Upvotes: 0

QuangAnh
QuangAnh

Reputation: 91

if you have multiple versions of ruby, I recommend you use RVM

Install it https://rvm.io/rvm/install

Use: https://github.com/wayneeseguin/rvm#usage

To view all versions of ruby use "rvm list"

and set default version "rvm --default version"

Upvotes: 0

Andrew Vyazovoy
Andrew Vyazovoy

Reputation: 580

Homebrew not so bad :) You may use rbenv. It is ruby version manager. My success story for MAC OS X 10.8.2 is:

  • install Homebrew
  • change PATH in /etc/paths (/usr/local/bin need to be first)
  • install rbenv and ruby-build (it is plugin for rbenv) using homebrew
  • create ~/.profile with content:

    export RBENV_ROOT=/usr/local/opt/rbenv
    
    if which rbenv > /dev/null; then
        eval "$(rbenv init -)"
    fi
    
  • install last stable ruby version using rbenv install 1.9.3-p374

  • change default ruby version using rbenv global 1.9.3-p374
  • update gem using gem update --system (optional)
  • install rails gem install rails
  • ...
  • Profit :)

Upvotes: 1

David Ryder
David Ryder

Reputation: 1311

bundle exec rails server

Should work just fine. It also worked for me to close the terminal and open a new one.

Upvotes: 0

bandola
bandola

Reputation: 367

If you are running mac os x you have ruby 1.8 preinstalled. Use RVM or rbenv if you want to have more than one ruby version installed.

Upvotes: 2

Related Questions