Rails rake给出冲突消息(rails 3.1)

时间:2011-10-08 14:00:47

标签: ruby-on-rails rake rvm

缩略路径:

me@michael-laptop:~/Dropbox_not_syncd/webs/3/tdd/rubyists$ rake db:create
.../rake/version.rb:4: warning: already initialized constant MAJOR
.../rake/version.rb:5: warning: already initialized constant MINOR
.../rake/version.rb:6: warning: already initialized constant BUILD
.../rake/version.rb:3: warning: already initialized constant NUMBERS
.../rake/version.rb:9: warning: already initialized constant VERSION
.../rake.rb:26: warning: already initialized constant RAKEVERSION
.../rake/early_time.rb:17: warning: already initialized constant EARLY
.../rake/alt_system.rb:32: warning: already initialized constant WINDOWS
.../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
.../rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
.../rake/invocation_chain.rb:49: warning: already initialized constant EMPTY
.../rake/file_utils.rb:10: warning: already initialized constant RUBY
.../rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
.../rake/dsl_definition.rb:143: warning: already initialized constant Commands
.../rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS
.../rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE
.../rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE
.../rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN
.../rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS
.../rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
.../rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS
.../rake.rb:64: warning: already initialized constant FileList
.../rake.rb:65: warning: already initialized constant RakeFileUtils
rake aborted!
stack level too deep

(See full trace by running task with --trace)

完整路径:

@michael-laptop:~/Dropbox_not_syncd/webs/3/tdd/rubyists$ rake db:create
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/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
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList
/home/me/.rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils
rake aborted!
stack level too deep

(See full trace by running task with --trace)

2 个答案:

答案 0 :(得分:1)

bundle exec rake db:migrate应解决此错误。我不久前遇到了同样的事情,这为我解决了。

答案 1 :(得分:1)

作为旁注,RVM不再将rake安装到全局gemset中,以便与特定ruby的每个gemset一起使用。这是密切相关的,因为我们这样做是为了你可以直接通过Gemfile和/或gemset安装rake PER-PROJECT。

我们非常鼓励每个项目的.rvmrc文件,以便将每个项目的宝石与其特定的宝石集分配隔离开来。这使得A)的“默认”和/或“全局”被污染,或者B)污染其他宝石。

每个安装的Ruby应该在'global'gemset中的唯一gem应该是bundler。

rvm x.x.x@global exec rvm gemset empty && rvm x.x.x@global exec gem install bundler && rvm --create use x.x.x@mygemset && gem list -l

将非常有效地证明这一点。此外,通过这种方式,您可以有效地消除

的需要
bundle exec ...