13

Possible Duplicate:
Rails 3.0 & Ruby 1.9.2rc: Rake commands return 'already initialized constant' & stack level too deep errors. Any ideas

Am using Ruby version 1.9.1 on windows vista. Am getting the rake aborted error for any rake commands am using. This does not happen in all my app folder. Its happening only on a specific app folder.

C:\rails_project\stunetwork>rake db:reset
(in C:/rails_project/stunetwork)
rake aborted!
stack level too deep
C:/Ruby191/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rak
efile'
(See full trace by running task with --trace)
Community
  • 1
  • 1
arun
  • 781
  • 2
  • 6
  • 14

6 Answers6

21

try placing bundle exec in front of the rake command.

bundle exec rake -T
dewil_de
  • 535
  • 4
  • 11
  • Not sure what the -T is for, but this worked for me. $bundle exec rake db:migrate – Kiran Aug 22 '11 at 04:46
  • -T just gives a list of all possible rake commands. – dewil_de Aug 23 '11 at 19:02
  • I'm new to Ruby on Rails, But i know that in my case bundler got installed as well... look at [Bundler](http://gembundler.com/) for more info – dewil_de Aug 27 '11 at 07:30
  • 1
    How do I fix it permanently? So I won't have to type `bundle exec` anymore.. – john2x Sep 04 '11 at 03:20
  • fyi the full rake list from -T is: `rake about rake assets:clean rake assets:precompile rake db:create rake db:drop rake db:fixtures:load rake db:migrate rake db:migrate:status rake db:rollback rake db:schema:dump rake db:schema:load rake db:seed rake db:setup rake db:structure:dump rake db:version rake doc:app rake log:clear rake middleware rake notes rake notes:custom rake rails:template rake rails:update rake routes rake secret rake stats rake test rake test:recent rake test:single rake test:uncommitted rake time:zones:all rake tmp:clear rake tmp:create` – Michael Durrant Oct 08 '11 at 16:52
  • Tried bundle rake db:reset and I got this: Could not find command "rake". – 2myCharlie Apr 22 '19 at 15:09
3

You need to update your gem. I met this error with gem '1.8.10', and fixed by upgrading to 1.8.16

gem update --system

Rocky
  • 5,486
  • 8
  • 32
  • 36
  • true this was a bug and was fixed with https://github.com/rubygems/rubygems/commit/7d43f1418a048bac277344df962aafd00797230b - available in 1.8.16 – mpapis Feb 16 '12 at 12:11
  • Tried that and got this: Latest version already installed. Done. – 2myCharlie Apr 22 '19 at 15:10
2

I only had this problem with ruby-1.9.2-p180 via rvm.

Switching to ruby-1.9.2-p0 fixed the problem. try "rvm use 1.9.2-p0"

flunder
  • 504
  • 6
  • 9
0

The stack of the calls can depend on the gems you install (some gems monkeypatch the rails tasks) which explains why you would encounter this on a specific app and not on others.

On a unix system you could try using the ulimit command to increase your stack size. On the windows side I haven't found a solution yet.

Depending on which release of ruby you use on windows you may want to ask the maintainers how to increase the stack.

For ruby installer you will need to install the mingw compile environment, clone the github repository and recompile the ruby you use (not very sexy I admit).

Jean
  • 21,329
  • 5
  • 46
  • 64
  • I liked this, thanks! Unfortunately wasn't enough. I set: "ulimit -s unlimited" then checked "ulimit -a" and stack is unlimited. It still says the same "stack too deep" error. What be be the reason? – YogiZoli Aug 05 '11 at 23:21
0

I just encountered this exact error message on Ubuntu, and was able to solve it by downgrading rubygems from 1.8.3 to 1.7.1.

Community
  • 1
  • 1
Tobias Cohen
  • 19,893
  • 7
  • 54
  • 51
  • 1
    As Rubygems 1.7.1 was released on April 1, 2011, and this question was asked on August 11, 2010, it may have been a different problem, even if the error messages were similar. – Andrew Grimm May 24 '11 at 23:08
  • 5
    @Andrew yes, that's quite likely. However, since this solution took me a while to work out and solved my problem, I thought it would be a good idea to post it here, even at the risk of confusing people from 2010. – Tobias Cohen May 26 '11 at 02:09
  • I am having this issue as well. It seems that version 1.8.10 is incompatible with rake 0.8.7. – B Seven Sep 10 '11 at 18:19
  • this bug was fixed in rubygems 1.8.16, just update to latest version – mpapis Feb 16 '12 at 12:13
0

There is nice post by Yehuda Katz that explains why without bundle exec there can be version conflicts: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

There is also bundle install --binstubs command that allows to version-safely run rake db:reset like this: bin/rake db:reset.

Alexey
  • 3,843
  • 6
  • 30
  • 44