Question

I am trying to run rake db:migrate in my Ruby on Rails application.

However, it is giving me a "uninitialized constant" exception. From Googling this, it looks like the solution is to update the rake version. So I changed my gemfile and ran bundle update.

However, the exception is still happening... I think because I didn't update the right rake library.

How do I fix this? How can I update rake for the other path too, or exclusively run rake through the bundle thing?

My-Comp:my_project username$ bundle show rake
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2
My-Comp:my_project username$ which rake
/usr/bin/rake
My-Comp:my_project username$ rake -V
rake, version 0.8.7

(See - they are not the same!)

My-Comp:my_project username$ rake db:migrate --trace
(in /Users/username/projects/my_project)
rake aborted!
uninitialized constant Rake::DSL
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2503:in `const_missing'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/tasklib.rb:8
/Library/Ruby/Gems/1.8/gems/rdoc-3.12/lib/rdoc/task.rb:37:in `require'
/Library/Ruby/Gems/1.8/gems/rdoc-3.12/lib/rdoc/task.rb:37
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks/documentation.rake:2:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks/documentation.rake:2
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:15:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:15
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:6:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/tasks.rb:6
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:289:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:289:in `initialize_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `instance_exec'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie.rb:184:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/engine.rb:424:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/application.rb:145:in `load_tasks'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/username/projects/my_project/Rakefile:7
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2383:in `load'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2383:in `raw_load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2017:in `load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2016:in `load_rakefile'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2000:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:31
Was it helpful?

Solution

Try this command:

bundle exec rake db:migrate

bundle exec executes a command in the context of your gemfile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top