Following this tutorial, I applied the steps for deploying to Heroku under 2.3.5 Deploying the demo app.
When I run the command: > heroku rake db:migrate, I get the following:
$ heroku rake db:migrate
(in /app)
rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:Ta
skLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:R
ake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (req
uired)>'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/task.rb:37:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/task.rb:37:in `<top (require
d)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `block
in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top (
required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
`require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
`initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:in
`load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in
`method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'
Why is that? And, how can I solve this issue?
Thanks.
I have a blog post about it here:
http://codeglot.com/posts/13-you_have_already_activated_rake_0_9_2
You have two options. Keep the latest gem and do this:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
Or you need to specify the older version of rake:
gem list
Then see which version of rake you have.
gem uninstall rake -v=0.9.1
Then in your bundler specify the older version:
gem 'rake', '0.8.7'
This link may help: fix unitialized constant rake heroku
Form that post:
Put this in your Rakefile above require 'rake':
require 'rake/dsl_definition'
Related
I just upgraded Ruby 2.2.2 to 2.3.0. Whenever I run a rake task I get the following error:
Christians-Air:my_rails_app cman77$ rake --trace
rake aborted!
NameError: uninitialized constant I18n::Config::Backend
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/i18n-0.7.0/lib/i18n/config.rb:19:in `backend'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/i18n-0.7.0/lib/i18n.rb:147:in `translate'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/actionview-4.2.6/lib/action_view/helpers/translation_helper.rb:69:in `translate'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/i18n-0.7.0/lib/i18n/config.rb:19:in `backend'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/i18n-0.7.0/lib/i18n.rb:147:in `translate'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/actionview-4.2.6/lib/action_view/helpers/translation_helper.rb:69:in `translate'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:658:in `block in run_tasks_blocks'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:658:in `each'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:658:in `run_tasks_blocks'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/application.rb:452:in `run_tasks_blocks'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/engine.rb:453:in `load_tasks'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/railtie.rb:194:in `public_send'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/railties-4.2.6/lib/rails/railtie.rb:194:in `method_missing'
/Users/cman77/Dropbox/rails_projects/my_rails_app/Rakefile:9:in `<top (required)>'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:93:in `load_rakefile'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:77:in `block in run'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/bin/rake:23:in `load'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/bin/rake:23:in `<main>'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/cman77/.rvm/gems/ruby-2.3.0#jbio.3.0/bin/ruby_executable_hooks:15:in `<main>'
Anyone have experience with this? I am really stuck in terms of how to even begin to diagnose/remedy this issue.
Here is the contents of my Rakefile:
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
ENV['NEWRELIC_ENABLE'] = 'false'
MyRailsApp::Application.load_tasks
This appears to be the offending line referenced in the I18n gem:
https://github.com/svenfuchs/i18n/blob/master/lib/i18n/config.rb#L18
Update: it seems to be tied to the use of include ActionView::Helpers::TranslationHelper in one of my rake files. If I remove that line I can run rake commands.
Update2: Removing include ActionView::Helpers::TranslationHelper and replacing (t "some_text") with (I18n.t "some_text") completely resolved the issue. I will still award the bounty to anyone who can explain why this broke with a Ruby upgrade!
My guess is that you experienced that problem because you ere using the t method (an helper for controllers and views) in a rake task, instead of the standard I18n.t.
This is an uncommon and unconventional approach, so you have fallen in a possible regression that few have experienced and it has a simple solution, like the one you found: stick to the conventions.
I've already seen some different answers, but none of these helped me...
This is the trick: I have to fix this without touching the Gemfile. I'm currently creating my working environment so that it matches the production server, so, I cannot modify the rails' code at all.
My OS: OSX 10.11
Ruby: ruby 2.0.0p643
Rails: 4.0.0
The gem is the Gemfile as gem 'mysql2'. There are no errors when doing bundle install, but when I try to rake db:migrate --trace this is the output:
rake aborted!
There was an error while trying to load the gem 'mysql2'.
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
/Users/redar/redar/config/application.rb:7:in `<top (required)>'
/Users/redar/redar/Rakefile:4:in `require'
/Users/redar/redar/Rakefile:4:in `<top (required)>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/rake:23:in `load'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/rake:23:in `<main>'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
/Users/redar/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `<main>'
I don't know how to interpret this. Is there something wrong with the Rakefile?
Also, this is the output from the mkmf.log
EDIT: This is the content of my Rakefile, located at myapp/folder
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
MyApp::Application.load_tasks
Try
bundle exec rake db:migrate
This will make sure that you are executing "rake db:migrate" with the gems listed in the Gemfile loaded and available. If you run it without "bundle exec" you may be executing only with the system gems available.
Anyone could help me?
I searched the same problem, but I can't figure out a solution still.
I ran successfully with "bundle update" "bundle install" but when running "rake db:migrate" I got the following problem...
rake aborted!
uninitialized constant Rake::DSL
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:8:in `<clas
s:TaskLib>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:6:in `<modu
le:Rake>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/tasklib.rb:3:in `<top
(required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rdoc-3.11/lib/rdoc/task.rb:37:in `<top (requ
ired)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation
.rake:2:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `blo
ck in <top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each
'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top
(required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:
in `initialize_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:
in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:i
n `method_missing'
C:/F/desktop/Projects/recle/recle/rails/eway/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `load'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
C:/Ruby192/lib/ruby/1.9.1/rake.rb:1991:in `run'
C:/Ruby192/bin/rake:31:in `<main>'
Put this in your Rakefile above require 'rake':
require 'rake/dsl_definition'
OR if the above solution does not work,
write this in your gemfile for rake
gem "rake", "0.8.7"
and go to command prompt and write.
gem uninstall rake
This will uninstall the existing rake gem.
Then type bundle update in your project folder which will install rake 9.8.7 again.
And enjoy rails :).
Why am I getting an error when I try to update my Heroku database?
Whenever I try any heroku rake... command I get the same error:
$ heroku rake db:setup
(in /app)
rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:Rake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks/documentation.rake:1:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks/documentation.rake:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:15:in `load'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:15:in `block in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:6:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:215:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:215:in `initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:139:in `load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:77:in `method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'
Rakefile should include
require 'rake/dsl_definition'
There are two ways to fix this. I have a blog post about it here:
Use an older rake version, or require DSL for the newer gem.
http://codeglot.com/posts/13-you_have_already_activated_rake_0_9_2.
sadly, including require 'rake/dsl_definition' did not work for me. I am using rails 3.0.6. So I reverted back to rake 0.8.7.
I have upgraded rails 2.3.11 to rails 3.0.8 using rails_upgrade plugin. Now I am getting this error and I do not understand why. Any help you can provide is appreciated!
rake aborted!
no such file to load -- tasks/rails
/home/mpn/mpn_admin/branches/to_rails3/Rakefile:13:in `require'
/home/mpn/mpn_admin/branches/to_rails3/Rakefile:13:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
Check your RakeFile to make sure it doesn't have the old Rails 2 artifacts left in it. The error is getting thrown in the RakeFile so that's probably the cause and the upgrade plugin would not have caught that.
Here is what a sample Rails 3 RakeFile looks like:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
MyAppNameGoesHere::Application.load_tasks