4

Like most Rails developers, I have lots of Rails apps on my system--running different versions of Rails. As a result, I've now got multiple versions of Rake (0.8.7 and 0.9.2).

Each of the apps is deployed on its own VPS, running just one version of Rails and one version of Rake.

Additionally, there are other developers on these projects that have their own setups, who may or may not have the same (or both) versions of Rake.

What is the best practice for managing this?

Should I specify a version of Rake in my Gemfile (for Rails 3 apps, using Bundler)? If I do so, then I always need to bundle exec rake, which is fine--but I wonder if that's now the standard. Does everyone have to do this? Is there a way to avoid it?

Also, as noted elsewhere, I have to update my Rakefile with

require 'rake/dsl_definition'
include Rake::DSL

if I want to use Rake 0.9.2. Even then, I get these warnings:

/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/Library/Ruby/Gems/1.8/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED

Should I just specify 0.8.7 in my Gemfile? It seems like I should be able to use 0.9.2.

I (a) need the app on the server to work without bundle exec, so simple things like rake db:migrate work, and (b) need something that will play nicely with other developers.

How are folks handling this? What seems to work well? What doesn't?

Any feedback would be greatly appreciated!

Community
  • 1
  • 1
ideaoforder
  • 1,023
  • 2
  • 9
  • 23

2 Answers2

4

If you use RVM and and gemsets, you can avoid the bundle exec problem all together.

For instance, every app or project I make gets its own gemset.

Example usage:

rvm use 1.9.2; rvm gemset create foobar

Then in the applications .rvmrc file:

rvm use 1.9.2@foobar

This will make rvm use the proper gemset and you wont have version collisions or be stuck using bundle exec for life.

Once you create the .rvmrc file don't forget to cd out and then back in or issue a

rvm reload

to start using the new gemset

Josh
  • 945
  • 9
  • 19
3

Using bundles and calling the right version with bundle exec rake is pretty much the way to go. That said, typing all of that gets old fast.

What you can do is bundle install --binstubs which will include executable stubs for the gems you use. Then you can simply call (e.g.) bin/rake cucumber:ok

David Sulc
  • 25,946
  • 3
  • 52
  • 54