The rake broke off! Uninitialized Permanent Rake :: DSL on Heroku

While trying to rake db:migrate on Heroku . I get the following error.

 rake aborted! uninitialized constant Rake::DSL 

From what I put together, this seems like a mistake with Rake . 0.9.2. If I use the "gem list", only Rake (0.8.7) is installed locally.

I tried adding "gem" rake "," 0.8.7 "to my gem file and starting the package installation, but then I get the following error.

 You have requested: rake = 0.8.7 The bundle currently has rake locked at 0.9.2. Try running `bundle update rake` 

If I run bundle update rake , it will go back to 0.9.2 and I will go back to where I started.

Did I miss something obvious here?

+6
source share
5 answers

You must run the commands with the exec package to ensure that you get the appropriate dependencies. So run:

 bundle exec rake db:migrate 

For a more detailed post, see the Yehuda Katz blog post http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

If you still have problems, there seem to be several other people with the same question. How to fix the uninitialized persistent Rake :: DSL problem on Heroku? which they decided by adding the following to their Rakefile:

 require 'rake/dsl_definition' require 'rake' 
+10
source

I got this error when I do "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' .... ... .... .. etc... 

I fixed it by adding

 require 'rake/dsl_definition' 

in rakefile and then typed

 bundle update rake git add . git commit -m "Change RakeFile" git push heroku heroku rake db:migrate 

This solved my problem. I have not added gem 'rake', '0.8.7' to my gem file and my gem list shows a rake (0.9.2, 0.8.7).

+3
source

I have a blog post about this, you have already activated Rake 0.9.2 . There are two ways to do this:

Use only the old version of Rake:

Check out current versions of Rake with $ gem list . See which versions of Rake you have and uninstall them all except 0.8.7 . You can remove gems with gem uninstall rake -v=0.9.1 or any other version you want to remove.

Or just add one liner to your Rake file:

If you do not need the old version of Rake, it is easier to add this line require 'rake/dsl_definition' to your Rails Rails file.

 require File.expand_path('../config/application', __FILE__) require 'rake/dsl_definition' require 'rake' 
+1
source

I used this to solve this problem earlier without removing any gems. This method will force your application to use Rake 0.8.7, which is more stable than 0.9+. You must run the bundle update rake command after specifying the version of Rake to use so that your gemfile.lock file gemfile.lock synchronized with your gem file (if you skip this step, Heroku will not let you push your code!)

In your gem file, specify the version of Rake to use:

 "rake", "0.8.7" 

Then do:

 bundle update rake 

If this does not work for you, follow these steps:

 sudo gem uninstall rake 
0
source

As with the rich answer (solving this problem without removing any gems), but adjusted for your step 1. and a few additional steps:

  • In the gem file, specify:

     gem 'rake', '0.8.7' 
  • bundle install (Bundler documentation says you always need to โ€œbind installationโ€ after modifying your gem file)

  • git commit -am "Fixed heroku rake problem by specifying rake 0.8.7 in Gemfile"

  • git push heroku

  • heroku rake db:migrate

I got the same error without steps 3 and 4.

0
source

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


All Articles