Multiple Rake Versions - Best Practice

Like most Rails developers, I have many Rails applications on my system β€” running different versions of Rails. As a result, I now have several versions of Rake (0.8.7 and 0.9.2).

Each application is deployed on its own VPS, starting only one version of Rails and one version of Rake.

In addition, these projects have other developers who have their own settings, 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 applications using the Bundler)? If I do, then I always need bundle exec rake , which is good - but I wonder if this is the standard now. Is there any need to do this? Is there any way to avoid this?

Also, as stated 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 indicate 0.8.7 in my Gemfile? It looks like I should use 0.9.2.

I (a) need the application on the server to work without bundle exec , so simple things work like rake db:migrate , and (b) you need something that works great for other developers.

How do people deal with this? What seems to work well? What not?

Any feedback would be greatly appreciated!

+4
source share
2 answers

Using bundles and invoking the correct version with bundle exec rake is pretty much the way to go. Nevertheless, having typed all this, he quickly gets old.

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

+3
source

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

For example, every application or project that I create gets its own gemset.

Usage example:

 rvm use 1.9.2; rvm gemset create foobar 

Then in the application files .rvmrc:

 rvm use 1.9.2@foobar 

This will force rvm to use the correct gemset, and you will not run into a version or get stuck with the exec package for life.

Once you create a .rvmrc file, remember to exit it and then come back or release

 rvm reload 

to start using the new gemset

+4
source

Source: https://habr.com/ru/post/1384495/


All Articles