需要帮助解决RAILS 3.0.9迁移问题

时间:2011-07-26 02:56:39

标签: ruby-on-rails-3 rubygems migration stack rake

我遇到了一些严重的问题。我有一段时间没用过它,所以我经历了更新rvm,rails等等。我目前正在运行以下内容:

RVM -- rvm 1.6.25 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]

RAILS -- Rails 3.0.9

RUBY -- ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

我执行以下步骤:

rails new my_project

cd my_project

bundle install

rails g scaffold person first_name:string last_name:string

rake db:migrate

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

提前致谢!

2 个答案:

答案 0 :(得分:3)

从我的博客中复制了解决方案:http://joneslee85.wordpress.com/2011/07/29/howto-fix-rake-0-9-2-to-work-with-ruby-1-9-2-under-rvm/

最好的方式: 我不认为恢复到0.8.7是最好的答案,因为如果你用RVM编译1.9.2,你将碰到这个问题。以下是如何修复这个宝贝:

  • gem list | grep 'rake',您会看到此rake (0.9.2 ruby)。现在请注意关键字“ ruby​​ ”是邪恶的,它实际上是@global文件夹中rake的重复。我认为这可能是RVM的错误。
  • 现在我们需要删除rake,请执行:gem uninstall rake,当Y警告它会破坏依赖关系时说Y,如果它要求删除可执行文件'rake',则说Y.
  • 现在,再次检查gem list | grep 'rake',您只会看到rake (0.9.2)

这可以解决这个问题。

第二种方式:恢复到0.8.7

好的,你将无法卸载rake 0.9.2,因为RVM已将rake安装到@global文件夹中。所以这里是你如何在安装rake 0.8.7之前手动删除rake 0.9.2:

gem list -d rake

并注意输出中的安装在:/Users/mojo/.rvm/gems/ruby-1.9.2-p290@global 。你的不同之处请注意,现在我们需要用以下命令删除rake:

注意:请确保使用\

转义字符@
rm /Users/mojo/.rvm/gems/ruby-1.9.2-p290\@global/bin/rake
rm /Users/mojo/.rvm/gems/ruby-1.9.2-p290\@global/cache/rake-0.9.2.gem
rm -rf /Users/mojo/.rvm/gems/ruby-1.9.2-p290\@global/doc/rake-0.9.2/
rm -rf /Users/mojo/.rvm/gems/ruby-1.9.2-p290\@global/gems/rake-0.9.2/
rm /Users/mojo/.rvm/gems/ruby-1.9.2-p290\@global/specifications/rake-0.9.2.gemspec

接下来是使用gem install rake -v=0.8.7

安装rake 0.8.7

答案 1 :(得分:1)

删除rake 0.9.2并安装rake 0.8.7并查看它是否有效。

众所周知,rake 0.9.x分支完全打破了任何rails安装。