Rails 3.0 和 Rails 3.0 Ruby 1.9.2rc:Rake 命令返回“已初始化常量” &堆栈级别太深错误。任何想法
我正在尝试运行 Rails 3 beta 4 & Ubuntu 10.04 上的 Ruby 1.9.2rc。它最初工作正常,但在完成我的第一个捆绑安装/打包后,我现在在所有 Rails 项目中收到以下错误。即使是一个基本的“rails new testproject”,后面跟着一个 rake 也会显示错误消息。
简而言之,我很困惑。任何有关可能导致此问题的原因的帮助将不胜感激。
我注意到的唯一一件事(可能相关也可能不相关)是 ~/.bundle 文件中的目录是 ruby/1.9.1。我的机器上未安装 1.9.1 - 仅安装了 1.9.2rc。 ruby -v 带回 1.9.2
(in /home/john/Websites/sandbox/testerino)
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:32: warning: already initialized constant RAKEVERSION
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:404: warning: already initialized constant EMPTY_TASK_ARGS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:452: warning: already initialized constant EMPTY
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:960: warning: already initialized constant RUBY_EXT
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:964: warning: already initialized constant RUBY
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1033: warning: already initialized constant LN_SUPPORTED
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1242: warning: already initialized constant ARRAY_METHODS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1245: warning: already initialized constant MUST_DEFINE
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1249: warning: already initialized constant MUST_NOT_DEFINE
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1253: warning: already initialized constant SPECIAL_RETURN
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1259: warning: already initialized constant DELEGATING_METHODS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1569: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1575: warning: already initialized constant DEFAULT_IGNORE_PROCS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1612: warning: already initialized constant FileList
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1638: warning: already initialized constant EARLY
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1968: warning: already initialized constant DEFAULT_RAKEFILES
rake aborted!
stack level too deep
I'm trying to run Rails 3 beta 4 & Ruby 1.9.2rc on Ubuntu 10.04. It worked initially, but after doing my first bundle install/package, I now get the following errors in all rails projects. Even a basic 'rails new testproject' followed by a rake brings up the error messages.
In short, I'm stumped. Any help regarding what could be causing this would be very appreciated.
The only thing I noticed - which may or may not be relevant - is that the directory in the ~/.bundle files is ruby/1.9.1. 1.9.1 is not installed on my machine - only 1.9.2rc. ruby -v brings back 1.9.2
(in /home/john/Websites/sandbox/testerino)
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:32: warning: already initialized constant RAKEVERSION
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:404: warning: already initialized constant EMPTY_TASK_ARGS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:452: warning: already initialized constant EMPTY
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:960: warning: already initialized constant RUBY_EXT
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:964: warning: already initialized constant RUBY
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1033: warning: already initialized constant LN_SUPPORTED
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1242: warning: already initialized constant ARRAY_METHODS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1245: warning: already initialized constant MUST_DEFINE
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1249: warning: already initialized constant MUST_NOT_DEFINE
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1253: warning: already initialized constant SPECIAL_RETURN
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1259: warning: already initialized constant DELEGATING_METHODS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1569: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1575: warning: already initialized constant DEFAULT_IGNORE_PROCS
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1612: warning: already initialized constant FileList
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1638: warning: already initialized constant EARLY
/home/john/.bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1968: warning: already initialized constant DEFAULT_RAKEFILES
rake aborted!
stack level too deep
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我也遇到过这个问题。它似乎与您提到的 Rails 或 ruby 的特定版本无关,它们与我使用的版本不同(Rails 2.3.8、Rake 0.8.7、Ruby 1.9.1p378)。这似乎与捆绑器和耙子不能很好地协同工作有关。
这张灯塔门票。这是简短的版本:
一旦你这样做了,你的捆绑器就会变得有点混乱。此时,您必须清除 RUBYOPT 才能运行捆绑命令:
编辑:
再考虑一下,我不确定这是否一定是解决此特定问题的最佳方法。在采用这种方法之前,您可以尝试 Hiral Desai 的技巧和其他一些答案,因为这种方法会改变环境。
I've been running into this issue too. It doesn't seem to be related to the specific versions of rails or ruby you mention, which are different than the ones I'm using (Rails 2.3.8, Rake 0.8.7, Ruby 1.9.1p378). It seems to be related to bundler and rake not working well together.
A resolution that worked for me is mentioned at the bottom of this lighthouse ticket. Here is the short version:
Once you do this, you mess up bundler a little bit. At that point you have to clear RUBYOPT in order to run the bundle command:
EDIT:
Thinking about it a little more, I'm not sure this is necessarily the best way to address this particular issue. You might give Hiral Desai's tip and some other answers a try before resorting to this approach, since this one changes the environment.
恐怕更简单的解决方案是运行此命令而不是 rake db:migrate
I'm afraid the easier solution is running this command instead of rake db:migrate
根据 Eric W. 之前的消息,RUBYOPT 环境变量已设置。
如果您想退出由“bundle exec bash”打开的新 bash shell,则只需复制 RUBYOPT 环境行,退出 shell,然后输入“export RUBYOPT='THE ARGS THAT YOU COPIED FROM THE PREVIOUS ENVIRONMENT'
注意:这有效使用 ruby 1.9.2p180(2011-02-18 修订版 30909)[x86_64-darwin10.7.0]
、Rails 3.0.7、gem 1.8.0 和 Rake 0.8.7
As per the previous message from Eric W. the RUBYOPT environment variable is set.
If you want to exit the new bash shell that is opened by "bundle exec bash" then just copy the RUBYOPT environment line, exit the shell then type "export RUBYOPT='THE ARGS THAT YOU COPIED FROM THE PREVIOUS ENVIRONMENT'
Note: this works with ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
, Rails 3.0.7, gem 1.8.0 and Rake 0.8.7
bundle exec bash
对我有用bundle exec bash
works for me我通过将 rubygem 安装从 1.8.10 降级到 1.7.2 解决了这个问题。
I was able to solve this issue by downgrading my rubygem install from 1.8.10 to 1.7.2.
看起来像一个奇怪的递归
require
。您是否尝试卸载所有版本的
rake
并重新安装? 1.9.2rc 中有一个错误 影响 gem 加载,因此可能是它?我没有仔细研究它,因为很多人已经在密切关注它...注意:1.9.1 是 API 版本,所以它是正确的。
Looks like a strange recursive
require
.Did you try uninstalling all versions of
rake
and reinstalling it? There is a bug in 1.9.2rc affecting gem loading, so that might be it? I didn't look closely into it as many people are already following it closely...Note: The 1.9.1 is the API version, so it is correct.
我的根目录中有一个 .bundler 文件夹,该文件夹存在冲突。删除它对我来说是这样。
I had a .bundler folder on my root directory which was conflicting. Removing it did it for me.
在更新 rubygem (1.8.10) 和 bundler (1.0.18) 后我也遇到了这个问题,
我解决了将 rake 更新到 0.9.2
I've been running into this issue too after updating rubygem (1.8.10) and bundler (1.0.18)
I solved updating rake to 0.9.2
由于删除了 .rvmrc ,所以出现了这样的错误,
所以请确保您在正确的环境中运行 rake ;)
Just got such error because of deleted .rvmrc
So please make sure you running rake in correct environment ;)
如果您安装了 RVM,则将 rubygems 更新到 1.8.15 后就会开始出现此问题。问题是我在全局 gemset 和我的项目的 gemset 中安装了 rake。解决方案是只安装一台耙子。要将其从项目 gemset 中删除:
1. cd 到项目
2. gem卸载rake
If you have RVM installed, this issue can start to occur once you update rubygems to 1.8.15. The issue was that I had rake installed in the global gemset and my project's gemset. The solution was to have only one installation of rake. To delete it from the project gemset:
1. cd to the project
2. gem uninstall rake
另一种可能的解决方案在 http://rubyist-journal.com/2011/07/29/howto-fix-rake-0-9-2-to-work-with-ruby- 1-9-2-under-rvm/
似乎可以归结为在用户 gem 目录和系统范围内安装相同的 rake gem。删除其中任一即可解决问题。
Another possible solution is given at http://rubyist-journal.com/2011/07/29/howto-fix-rake-0-9-2-to-work-with-ruby-1-9-2-under-rvm/
It seems to boil down to having the same rake gem installed both in your user gem directory and system-wide. Removing either one fixes the issue.
当您在存储库的 rvm gemset 和全局 rvm gemset 中都安装了 rake gem 时,可能会发生这种情况。
This can happen when you have the rake gem installed in both your repo's rvm gemset and the global one.
更新到最新的 Rails 小版本。
因此,如果您使用的是 4.2,请更新 => 4.2.最新。
Update to latest Rails minor version.
So if you are at 4.2, update => 4.2.latest.