views:

2608

answers:

7

Hey i got an White Macbook and, has to go in 10 hours to a conference. And I'm having a lot of problems.

First, I wanted to have Rails 3, so I used MacPorts to install Ruby 1.8.7. It worked well ;) So now I was thinking I should install Rails 3.. but no, no!.. it says..

$ sudo gem install rails --pre

ERROR:   Error installing rails:

                 activesupport requires Ruby version >= 1.8.7.

So what can I do? I have 1.8.7 !

+1  A: 

You may have two different versions of Ruby installed. Try "gem env" or "sudo gem env" and see which version of Ruby it says you have.

Remove the older one if you have two installed. If all else fails, upgrade to 1.9.x, I believe it is recommended for Rails 3 anyway.

Zachary
It does say 1.8.6.. How do i get rid of that?
Oluf Nielsen
I don't own a Mac so I'm not 100% sure, but if you go the directory it says you have it installed in, there should be an uninstaller you can run.
Zachary
He should __NOT__ uninstall 1.8.6 - which is part of Apple's built-in system, and which some software may expect to be there. He can manage the different Rubies with a sane and simple use of his `$PATH` variable.
Telemachus
In my defense, he asked how to get rid of it, not if he should. XDJust goes to show how much I know about Mac's.
Zachary
+1  A: 

I would strongly recommend using RVM (Ruby Version Manager) to keep your Rails 3 separate from your Rails 2. (One example of Rails 2 conflicting with Rails 3: when you go to the command line to generate a Rails app, will it generate a Rails 2 app or a Rails 3 app? RVM allows you to keep them separate.)

Also, the latest Ruby 1.8.7 will probably not work with Rails 3, so you have to use an earlier patchlevel (248 works for me). Details are here: http://techiferous.com/2010/02/installing-rails-3-beta-with-rvm-and-ruby-1-8-7/

techiferous
+10  A: 

First you need to install RVM, then the latest version of Ruby. Next you'll set that version of Ruby as the default. Finally, you'll install Rails b3.

Install RVM (http://rvm.beginrescueend.com/rvm/install/):

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

Install the latest Ruby (http://rvm.beginrescueend.com/rubies/installing/):

rvm install ruby-head

You can check which versions you now have installed with:

rvm list

Set the latest version of Ruby as default (replace 'ruby-1.9.2-head' with desired version):

rvm ruby-1.9.2-head --default

Make sure things are up to day, then install the Rails beta:

gem update --system
gem install rails --pre

You may have to install some gem dependencies before Rails will install.

Jarrod
+1 Worked perfectly for me.
Owen
+1  A: 

You should use rvm as others have said to manage multiple installations of Ruby and Ruby gems. (If you go that way, take the time to read rvm's documentation carefully.)

However, you should also get comfortable figuring out what version of Ruby your shell is seeing as the default and why. It sounds to me like your $PATH variable may not be properly updated. The $PATH variable is what determines which Ruby interpreter or gem command is the first seen, if you have more than one installed (as you now do). MacPorts will install new binaries into /opt/local/bin by default, and it should also alter your $PATH so that /opt/local/bin precedes /usr/bin (which is where Apple's out of the box Ruby lives).

I suspect that when you did sudo gem install, you were using /usr/bin/gem (which is the gem installer for /usr/bin/ruby rather than /opt/local/bin/gem (which would be the installer for MacPort's Ruby).

Check the output of echo $PATH, which ruby and which gem to see what's going on.

Telemachus
+2  A: 

To easily setup Rails 3 on osx machine the only thing you need to do is follow this brilliant (as always) Railscast, here for the transcription

You can also see comments to check for problems and eventually solutions.

tommasop
+1 Railscast...
DJTripleThreat
A: 

Based on your question and your responses to some of the answers, it sounds like you're not using the MacPorts version of Ruby. You should make sure that /opt/local/bin is in the front of your $PATH, before /usr/bin. Also, you should install RubyGems via MacPorts (sudo port install rb-rubygems) and make sure you're using the MacPorts gem. Then install Rails using the MacPorts gem.

mipadi
A: 

You should indeed use rvm, but as no one explained to you how to do this without rvm, here you go:

sudo gem install tzinfo builder memcache-client rack rack-test rack-mount \
  abstract erubis activesupport mime-types mail text-hyphen text-format   \
  thor i18n rake bundler arel railties rails --prerelease --force
Konstantin Haase