2

Update and Solution

I finally got everything working after
1. Uninstalling everything ruby-related in /usr/local/... as well as uninstalling all versions of rails.
2. Installing RVM as a standard user -> i.e. installed in my home directory and NOT in /usr/local as root
3. rvm install 1.8.7 and set as default

Now everything seems to be working fine.

My conclusion after days of googling and reading about others' solutions is that Snow Leopard just doesn't handle the rails dev environment well unless you sandbox it through RVM in a local director. I resisted going to RVM because I don't have a need to manage multiple ruby versions.

Some of the responses below along with my code excerpts on pastie may provide some helpful advice for others trying to troubleshoot. In particular from @fl00r and @Kelvin:
run which -a for gem, bundle, rails, rake, etc. to see the available versions. Check to see which versions of ruby are being called with head -1 on each.

Original Below

Pretty much at my wit's end after a few days of Googling, uninstalling, and re-installing. I'm trying to get rails running on Mac OS X 10.6.7. I followed the Hivelogic Post on this topic. Apologize for the length of this question.

Has anyone followed a step-by-step uninstall/reinstall process for getting this working? Or a link to advice on troubleshooting? Should I clean out everything following this advice from Chad Wooley and migrate to RVM?

The common theme has been errors related to being unable to find gems even though they are installed. For instance, trying to create a new rails app:

kevindewalt@new-host-4:~/Documents$ $ rails new blog
You don't have i18n installed in your application. Please add it to your Gemfile and run bundle install

Or an existing app I have running on another machine after running bundle install:

kevindewalt@new-host-4:~/Documents/ClaimAway$ (master) $ rake db:setup
(in /Users/kevindewalt/Documents/ClaimAway)
Could not find i18n-0.4.2 in any of the sources
Try running `bundle install`.
kevindewalt@new-host-4:~/Documents/ClaimAway$ (master) $ rails s
/usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0/lib/action_dispatch.rb:35:in `require': no such file to load --

-

kevindewalt@new-host-4:~/Documents$ $ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.7.2
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.7.0]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-10
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/1.8
     - /Users/kevindewalt/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

-

kevindewalt@new-host-4:~/Documents$ $ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

-

kevindewalt@new-host-4:~/Documents$ $ which -a ruby
/usr/local/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
/usr/local/bin/ruby
Kevin Dewalt
  • 757
  • 9
  • 24
  • 1
    Have you tried using a version of rails more recent than 3.0.0 and see if that fixed your dependency issues? I'd also highly recommend using rvm: https://rvm.beginrescueend.com/ – Aaron Hinni Apr 14 '11 at 13:32
  • Another RVM fan here. rvm, rvmrc and gemsets make life easy. – revdrjrr Apr 14 '11 at 13:51
  • +1 for trying to be helpful to others with your level of detail. – Kelvin Apr 15 '11 at 18:56

4 Answers4

2

add to Gemfile

gem 'i18n'

Actually you should specify exact version also:

gem 'i18n', '0.4.2'

then run bundle install. But as far your i18n gem will be locked try this:

bundle update i18n

That is all what is written in your error.

fl00r
  • 82,987
  • 33
  • 217
  • 237
  • I'm assuming you mean 'gem install i18n'? Gems are already installed and bundle install runs fine. And of course that won't help with 'rails new myapp' or 'rails server'. Thanks for the suggestion though... – Kevin Dewalt Apr 14 '11 at 13:09
  • no, I don't think he does mean that, if you're using bundler you shouldn't really 'gem install' anything, put it in your gemfile, then run bundle install again, and +1 for using rvm – Nick Apr 14 '11 at 13:36
  • I mean just what I wrote :) 1. ADD TO GEMFILE `gem 'i18n'` and AFTER THAT rub `bundle install`. Why don't you try it? – fl00r Apr 14 '11 at 17:48
  • ok...my apology for not reading closer. I did try this and it didn't work. The challenge is that I've been chasing single error messages like this for days without diagnosing the root cause. But thanks for helping and sorry again. – Kevin Dewalt Apr 15 '11 at 11:30
  • You know what. I think you are using different Ruby for bundler and your Rails app. Try to check: `which ruby` and `which bundler` and `which rake` does it belongs to same Ruby dir? Also you can try to reinstall Rails gem – fl00r Apr 15 '11 at 12:21
  • Ok...now we're getting somewhere. Rake IS using a different ruby: http://pastie.org/1797273 – Kevin Dewalt Apr 15 '11 at 12:31
  • checkout if `/usr/local/bin/rake` exist and then just remove `rm /usr/bin/rake` – fl00r Apr 15 '11 at 12:36
  • Ok...reinstalled rake and fixed that problem. But other errors still keep popping up. http://pastie.org/1797352 Can't thank you enough for the help but I'm reaching the point where giving RVM seems like the right move. – Kevin Dewalt Apr 15 '11 at 13:02
  • Yes...2 minutes to get RVM running...that seems to be the experience of everyone except me with the cursed machine! http://pastie.org/1797204 Thanks again for the help, hopefully this journal will help out some other folks. @Kelvin – Kevin Dewalt Apr 15 '11 at 14:31
  • `There was an error, please check /usr/local/rvm/log/ruby-1.8.7-p334/*.log` – fl00r Apr 15 '11 at 15:03
  • yeah, I checked that first. empty. 'ls -la /usr/local/rvm/log/ total 0' – Kevin Dewalt Apr 15 '11 at 15:09
  • have you added: "The rvm installation documentation instructs you to put the following line at the very end of your bash profile: `[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.` – fl00r Apr 15 '11 at 15:18
  • going through that now, thanks. I should have RTF instructions before commenting..lazy on my part – Kevin Dewalt Apr 15 '11 at 15:25
1

rvm is probably your best bet to prevent problems like this. But it might be overkill if you actually don't need multiple ruby version or gemsets.

Let me try to diagnose the issue. If we can solve it, then you don't have to jump through the rvm hoops (unless you want to of course).

I suspect that when you run some of these ruby-based scripts like 'gem', 'bundle', 'rails', and 'rake' the shebang line of these scripts is pointing to a ruby installation that you didn't expect.

Here's my usual checklist of diagnosing gem issues like this.

  1. Run "which -a gem". Do you see multiple unique locations? If so, gem list using the full path to gem. E.g. "/usr/bin/gem list" and "/usr/local/bin/gem list". My guess is that you'll see that one of the lists has i18n and the other doesn't.
  2. Run "which" on rails, bundler, and gem. Run "head -1" on each of those paths. Does the ruby path match in all of them?

My guess is that the "rails" in your PATH is not using the same ruby as the "gem" in your PATH. Maybe you installed it with the preinstalled 'gem' command so it's pointing to the system ruby's gem directory rather than /usr/local. Try reinstalling rails, then closing and reopening your terminal. Then use the "which" and "head -1" above to make sure "rails" is using the same ruby as "gem" is.

Another suspect is the "sudo" command. You may also want to run the "which" command via sudo, e.g. sudo sh -c 'which gem'. It's possible that sudo is running one of the preinstalled scripts. If in doubt, you could run: "sudo /usr/local/bin/gem install rails" so you know for sure which gem command you're using.

Kelvin
  • 20,119
  • 3
  • 60
  • 68
  • Thanks for taking the time to write such detailed troubleshooting steps. This is what I've been looking for and regardless of whether it helps me I'm sure it will help someone. Unfortunately I followed these steps and documented at http://pastie.org/1797204 without any luck. I'm getting close to throwing in the towel and migrating to RVM. @fl00r – Kevin Dewalt Apr 15 '11 at 12:21
  • Can you also post the full error and backtrace that came after this (from your original question): `/usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.0/lib/action_dispatch.rb:35:in 'require': no such file to load --`. It's possible that this isn't a gem or ruby installation issue at all. – Kelvin Apr 15 '11 at 14:40
  • I actually uninstalled most of the ruby-related files at /usr/local/... to try and migrate to rvm. Unfortunately I'm encountering errors with it as well, so you might be right. http://pastie.org/1797611 Thanks again for the help. – Kevin Dewalt Apr 15 '11 at 15:02
  • Your rvm issue has to do with permissions. Since you installed rvm as root (via sudo), you'll need to use sudo every time you install rubies or gemsets. – Kelvin Apr 15 '11 at 15:58
  • Thanks for all of your help and advice. I finally got there, see my comments at the top. Even running as sudo I was getting weird results beyond permission issues. I'm quite sure your advice will be helpful to others. I could only accept one answer but voted up your response – Kevin Dewalt Apr 15 '11 at 17:39
0

I would do a couple of things.

Start by uninstalling Rails >= 3 from your current systems gem installation. This includes all Rails dependencies. You should be able to boot < Rails3 projects using your normal gem installation now.

Next up install rvm and use rvm to install Ruby 1.9.2 and Rails3. Use the 1.9.2 rvm to work with your Rails3 projects. Part of rails3 and rails2 don't work well together so you should always try to seperate them imho.

Maran
  • 2,751
  • 15
  • 12
0

See this stack question for step by step instructions for installing rails using rvm. This is the most tried and true method I've found:

Uninstall Ruby on Rails on Mac OS X 10.6

Community
  • 1
  • 1
Mike Farmer
  • 2,992
  • 4
  • 28
  • 32