views:

1523

answers:

5

I just set up a fresh Mac OS X 10.5 environment for Rails. I installed Ruby 1.8.7, renamed the packaged version of Ruby in /usr/bin, and updated the packaged version of RubyGems from 1.0.1 to 1.3.4. Here's the flow:

$ rails -v
Rails 2.3.4
$ gem -v
1.3.4
$ which gem
/usr/bin/gem
$ whereis gem
/usr/bin/gem
$ which rails
/usr/bin/rails
$ whereis rails
/usr/bin/rails
$ /usr/bin/gem -v
1.3.4
$ /usr/bin/rails -v
Rails 2.3.4
$ rails testapp
...
...
testapp $ script/console
Rails requires RubyGems >= 1.3.2.  Please install RubyGems and try again:  http://rubygems.rubyforge.org

The thing is I've updated RubyGems and didn't install another version of it. gem list rails displays two versions of Rails (2.3.4 and 1.2.6), though.

How can I fix this so I can use Rails?

A: 

Rails will tell you the version of RubyGems you have if it's loading an incompatible version. The error message you're getting means it can't load RubyGems at all, so I'm thinking it's a path issue.

What do you get from $: in irb? Is there a rubygems.rb in any of those locations?

Baldu
I didn't see it; how can I fix this? I don't get why it's not there when I just upgraded the existing RubyGems install on Mac OSX - wouldn't it have been set already?
Jack Of Hearts
I think I see the problem, but I'm not sure. running gem environment shows my Ruby version as 1.8.6 but I installed 1.8.7. I think because I only installed the new version of Ruby but kept and updated the original version of gems, there's some weirdness going on there.
Jack Of Hearts
FYI I'm keeping the default rubygems install because I ran into some issues trying to install things that expect the default gem location; I'm a newb to command line stuff :(
Jack Of Hearts
A: 

Make your life easier and use Macports instead of trying updatre and repalce the core system libraries. :-)

prodigitalson
+2  A: 

One suggestion is to not change the system versions, instead install in /usr/local or use MacPorts.

The guys over at HiveLogic cover Rails, as well as MySQL and other development tools.

Using these techniques i've successfully installed rails into /usr/local Then it's a simple matter of adjusting the path settings in your terminal shell via (export PATH=/usr/local/bin:$PATH)

Grant Sayer
+1  A: 

Have you tried:

sudo gem update --system

That should get you the latest version of rubygems, which is something like 1.3.5.

scottwb
A: 

I second that emotion and, if I could, would up-vote the answer from prodigitalson -- MacPorts is your friend... Recommend you run specifically:

$ sudo port install rubygem

$ gem install rails

Key is making your which ruby and your rubygems which gem in synch. and in harmony...both should be in /opt/local/bin/

So Ruby on Rails 2.3.8 working on my MacOS 10.5.8 - and the gem environment no longer lies after the MacPorts install and reports the correct version, 1.8.7.

$ gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.4
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
  - INSTALLATION DIRECTORY: /opt/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /opt/local/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-9
  - GEM PATHS:
     - /opt/local/lib/ruby/gems/1.8
     - /Users/saleram/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
mikesalera