Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do you activate or set the default rake?

I have seen many

You have already activated rake 0.9.x, but your Gemfile requires rake 0.x.x

errors.

Of course, they can be solved (temporarily or always) by some methods like the following.

bundle exec rake

The method above works but you always have to type bundle exec.

It can also be solved by

bundle update

But bundle update also updates your other gems.

Some say it can be solved by

gem uninstall unwanted_rake_version

Yes, the unwanted rake can be installed but it is still marked as activated thus, still giving the error.

One solution would be to explicitly specify the rake version in your Gemfile but, that is not the question. It is on how to set the default rake version, or activate that specific version in rvm or other types of ruby installations?

like image 667
poymode Avatar asked Jul 12 '11 14:07

poymode


People also ask

How do I activate a different version of Rake?

The newer versions of rake can be activated by supplying an optional first argument, that is the gem version. Alternatively, if you have an older version of rake you can update the rake script manually to include this parameter (or specify any specific version you want).

What is environment rake task?

Including => :environment will tell Rake to load full the application environment, giving the relevant task access to things like classes, helpers, etc.


1 Answers

The newer versions of rake can be activated by supplying an optional first argument, that is the gem version.

$ rake 0.9.2

Alternatively, if you have an older version of rake you can update the rake script manually to include this parameter (or specify any specific version you want).

The rake script usually lives in /usr/bin/rake (or ~/.rvm/gems/ruby-#{ruby-name}/rake if using rvm). And dictates the version of them gem to load before parsing paramaters.

It looks like this on my system.

$ cat ~/.rvm/gems/ruby-1.9.2-p180/bin/rake

#!/home/tomcat/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem 'rake', version
load Gem.bin_path('rake', 'rake', version)

The important bit is gem 'rake', version changing version will force rake to a specific version system/rvm wide.

For more info, Katz' article explains nicely how binaries run under rubygems

like image 145
diedthreetimes Avatar answered Oct 17 '22 19:10

diedthreetimes