耙子错误:堆栈级别太深

时间:2011-10-03 05:19:55

标签: ruby ruby-on-rails-3 rake

我知道这是一个常见问题,但我刚刚开始使用新的Rails 3.1.0和Ruby 1.9.2 p290

在我第一次迁移时,我已经出现了这个错误,我不知道为什么。

Aurelien$ rake db:migrate --trace
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/application.rb:28: warning: already initialized constant DEFAULT_RAKEFILES
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
stack level too deep
/Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rake-0.9.2/lib/rake/task.rb:162

我还删除了gems并使用db:reset重新编译     来源'http://rubygems.org'

gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

#gem "rspec-rails", :group => [:test, :development]

group :test do
  #gem "factory_girl_rails"
  #gem "capybara"
  #gem "guard-rspec"
  #gem "spork", "> 0.9.0.rc"
  #gem "guard-spork"
end

rake命令适用于bundle exec,但避免使用它会很好。

提前感谢您提供的提示和解答。

的Aurelien

1 个答案:

答案 0 :(得分:5)

你应该在你的Gemfile中专门添加Rake版本> = 0.9.2! 某些Rails 3版本存在一个错误,当您使用较旧的Rake版本时,您会看到类似的奇怪错误。

在你的Gemfile中:

gem 'rake' , '>= 0.9.2'

我还建议您专门为您的应用程序创建一个新的gemset,例如

rvm gemset create yourproject
rvm gemset use yourproject

或:

rvm gemset use yourproject --default

对于新的gemset,你可能需要手动添加“gem install rake”,然后运行“bundle install”

除了使用Gemfile之外,使用单独的gemset是保持项目中的gem版本稳定并与其他项目分离的最佳方法。