uninitialized constant Rake::DSL Ruby Windows Solution

rake aborted!
uninitialized constant Rake::DSL
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2482:in `const_missing’
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.1/lib/rake/tasklib.rb:8:in `’

Now, the first step I took towards solving this problem is to issue “bundle update rake” command to update my rake. This will update rake to the latest version. An example log for this update is provided below;

bundle update rake
Fetching source index for http://rubygems.org/
Using rake (0.9.1)
Using abstract (1.0.0)
Using sqlite3 (1.3.3)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed

Now,Once this step is done you can check the version of Rake by using the command “bundle show rake”. The version of Rake came out to be 0.9.1. Now, inside your application you need to edit your Rakefile as shown below;

require File.expand_path(‘../config/application’, __FILE__)
require ‘rake’
#Use correct application name that matches for you
module ::Blog
class Application
include Rake::DSL

module ::RakeFileUtils
extend Rake::FileUtilsExt


Also had to add require ‘rake/dsl_definition’ above require ‘rake’ in your Rakefile

if the rake version is less then 0.9.2 these problem will occure,
just put gem install rake -v=0.9.2
and bundle update

add this module in your rake file

module ::YourApplicationName
class Application
include Rake::DSL


try this first

gem update rake

Permanent link to this article: https://blog.openshell.in/2011/07/uninitialized-constant-rakedsl-ruby-windows-solution/

Leave a Reply

Your email address will not be published.