1

I'm trying to get a Ruby on Rails project started on Dreamhost, ruby version 1.8.7 I can't check the rails version because of the rake problem but I believe it's at least 3.0. I was having trouble getting the mysql2 connector to work with rake db:migrate and I was trying different versions of gems, and I installed a local version of bundle on ~/.gems, then uninstalled it, and now bundle and rake don't see the gems installed in /usr/lib/ruby/gems/1.8/bin.

I tried following http://wiki.dreamhost.com/Rails_3 to see if it was a path issue before I realized the local bundle gem may have caused the problem, and I erased my PATH by not including :$PATH at the end of the export command the first time. I looked up common $PATH variables and after following the link above the following are set to:

$GEM_HOME = ~/.gems

$GEM_PATH = /usr/lib/ruby/gems/1.8

$PATH = ~/.gems/bin:/usr/lib/ruby/gems/1.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

So now I'm not quite sure if there was something in the $PATH that is now missing, or if it was the bundle install/uninstall in ~/.gems that make it so when I try to run rake db:migrate or bundle exec rails console I get the error "Could not find rake-0.8.7 in any of the sources".

EDIT: I tried following the directions on http://forums.site5.com/showthread.php?p=87539 so I added the GEM_PATH in environment.rb which points to the local and shared gem directories, ran irb and tried require 'rubygems' and require 'rake' which both worked, $: showed the correct version of rake, but still get the same error when trying to run rake db:migrate in the RoR app directory, "Could not find rake-0.8.7 in any of the sources".

EDIT: After getting rvm setup I was at the same spot, but after reading http://muffinlabs.com/content/rvm-and-bundler-dreamhost I changed the GEM_HOME and GEM_PATH vars (in config/evironment.rb instead of config.ru) to the rvm setup ones and rake no longer gives the "Could not find rake" error. The mysql2 adapter still doesn't work but that's another issue.

element8
  • 105
  • 2
  • 9

1 Answers1

1

Use rvm. It handles any number of different versions of rubies and gems to avoid exactly this kind of headache.

Thilo
  • 17,565
  • 5
  • 68
  • 84
  • I installed rvm and followed the steps in the project folder to get it setup, but after I installed rake, bundler, and mysql2 gems it gives me the same error when trying to run `rake db:migrate`. I installed the same version of ruby and the gems that dreamhost is using (rake-0.8.7, mysql2-0.3.7, bundler-1.0.7, and ruby 1.8.7 patch level 357). Looking at the output for `gem environment` looks like rvm set everything up properly. – element8 Jan 16 '12 at 10:59
  • 1
    What's the output of `which rake`? It should point to the one under your .rvm directory. Try running `bundle exec rake ...` instead of just `rake ...`. – Thilo Jan 16 '12 at 11:18
  • after changing the vars in evironment.rb it shows the rvm path with `which rake` and runs without the same error, thanks! updated the original post with the whole fix. – element8 Jan 16 '12 at 11:20