耙子宝石问题

发布于 2024-11-28 10:59:09 字数 1729 浏览 4 评论 0原文

我有这个 ruby​​ on Rails 项目,我想做 db:migrate。但我得到的唯一 rake 选项是“重新加载 rake 任务”,所以当我点击该选项时,它会给我这个错误。

[rake --tasks] rake aborted!
uninitialized constant Rake::DSL
/usr/lib/ruby/1.8/rake.rb:2503:in `const_missing'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/tasklib.rb:8
/var/lib/gems/1.8/gems/rdoc-3.9.1/lib/rdoc/task.rb:37:in `require'
/var/lib/gems/1.8/gems/rdoc-3.9.1/lib/rdoc/task.rb:37
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks/documentation.rake:2:in `require'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks/documentation.rake:2
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:15
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:6
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:215:in `require'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:215:in `initialize_tasks'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:139:in `load_tasks'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `send'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
/home/laptop/RubymineProjects/auth/Rakefile:7
/usr/lib/ruby/1.8/rake.rb:2383:in `load'
/usr/lib/ruby/1.8/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/1.8/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/1.8/rake.rb:2000:in `run'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:28

谢谢,迈克尔。

I've got this ruby on rails project and I want to do db:migrate. But the only rake option I got is "Reload rake tasks" so when I hit that, it gives me this error.

[rake --tasks] rake aborted!
uninitialized constant Rake::DSL
/usr/lib/ruby/1.8/rake.rb:2503:in `const_missing'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/tasklib.rb:8
/var/lib/gems/1.8/gems/rdoc-3.9.1/lib/rdoc/task.rb:37:in `require'
/var/lib/gems/1.8/gems/rdoc-3.9.1/lib/rdoc/task.rb:37
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks/documentation.rake:2:in `require'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks/documentation.rake:2
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:15
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/tasks.rb:6
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:215:in `require'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:215:in `initialize_tasks'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:139:in `load_tasks'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `send'
/var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
/home/laptop/RubymineProjects/auth/Rakefile:7
/usr/lib/ruby/1.8/rake.rb:2383:in `load'
/usr/lib/ruby/1.8/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/1.8/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/1.8/rake.rb:2000:in `run'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:28

Thanks, Michael.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎夕旧梦 2024-12-05 10:59:09

这是一个常见问题。只需按照以下步骤操作:

gem install rake -v=0.9.2(如果您有 0.9.1 gem)

gem uninstall rake -v=0.9.1(如果您有有 0.9.1 gem)

查看您的日志,我发现您有 rake-0.9.2 所以我认为您可以跳过上面的 2 个步骤。

bundle update

然后,运行 db:migrate 会出现如下错误: 警告:不推荐对 Rake DSL 方法的全局访问

要解决此问题,您只需将这两行添加到 Rakefile 的顶部

require 'rake/dsl_definition'

include Rake::DSL

它应该可以工作完美之后就好了!

This is a common problem. Just follow these steps:

gem install rake -v=0.9.2 (If you have the 0.9.1 gem)

gem uninstall rake -v=0.9.1 (If you have the 0.9.1 gem)

Looking at your logs, I see you have rake-0.9.2 so I think you can skip the 2 steps above.

bundle update

Then, running db:migrate will give you an error like this: WARNING: Global access to Rake DSL methods is deprecated

To solve, this you just have to add these two lines to the top of your Rakefile

require 'rake/dsl_definition'

include Rake::DSL

It should work perfectly fine after that!

最单纯的乌龟 2024-12-05 10:59:09

您应该在 Gemfile 中特别添加 Rake 版本 >= 0.9.1!
某些 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”

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

You should specifically add Rake version >= 0.9.1 in your Gemfile!
There was a bug with some Rails 3 versions where you would see strange errors like this when you use an older Rake version.

In your Gemfile:

gem 'rake' , '>= 0.9.2'

I'd also recommend you create a new gemset specifically for your application, e.g.

rvm gemset create yourproject
rvm gemset use yourproject

or:

rvm gemset use yourproject --default

for the new gemset, you might have to add "gem install rake" manually, then run "bundle install"

Using a separate gemset in addition to using your Gemfile is the best way to keep your gem versions in your project stable, and decoupled from other projects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文