雷克流产了! Heroku 上未初始化的常量 Rake::DSL
尝试在 Heroku 上rake db:migrate
时。我收到以下错误。
rake aborted!
uninitialized constant Rake::DSL
据我所知,这似乎是 Rake 0.9.2 的一个错误。如果我在本地执行“gem list”,则只会安装 Rake (0.8.7)。
我尝试将“gem 'rake', '0.8.7'”添加到我的 gem 文件中并运行捆绑安装,但随后出现以下错误。
You have requested:
rake = 0.8.7
The bundle currently has rake locked at 0.9.2.
Try running `bundle update rake`
如果我确实运行bundle update rake
,它会恢复到0.9.2,并且我又回到了开始的地方。
我在这里遗漏了一些明显的东西吗?
When trying to rake db:migrate
on Heroku. I'm getting the following error.
rake aborted!
uninitialized constant Rake::DSL
From what I've gathered this seems to be a bug with Rake 0.9.2. If I do "gem list" locally only Rake (0.8.7) appears to be installed.
I've tried adding "gem 'rake', '0.8.7'" to my gem file and running bundle install but then I get the following error.
You have requested:
rake = 0.8.7
The bundle currently has rake locked at 0.9.2.
Try running `bundle update rake`
If I do run bundle update rake
, it reverts back to 0.9.2, and I'm back where I started.
Am I missing something obvious here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该使用bundle exec 运行命令以确保获得正确的依赖项。因此,运行:
有关更详细的帖子,请参阅 Yehuda Katz 博客文章 http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
如果您仍然遇到问题,似乎还有其他几个人也遇到同样的问题 如何修复 Heroku 上未初始化的常量 Rake::DSL 问题? 他们通过将以下内容添加到 Rakefile 中解决了这个问题:
You should run commands with bundle exec to ensure your getting the proper dependencies. So run:
For a more detailed post see Yehuda Katz blog post http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
If you still continue to have problems there appears to be several other people with the same issue How to fix the uninitialized constant Rake::DSL problem on Heroku? which they resolved by adding the following to their Rakefile:
我在执行“heroku rake db:migrate”时遇到此错误。
在
/app
中:我通过添加
RakeFile 来修复它,然后输入
This one 解决了我的问题。我没有在 gem 文件中添加
gem 'rake', '0.8.7'
我的宝石列表显示 rake (0.9.2, 0.8.7)。
I got this error when doing "heroku rake db:migrate".
In
/app
:I fixed it by adding
in RakeFile and then typed in
This one solved my problem. I didn't add
gem 'rake', '0.8.7'
in my gem fileand my gem list shows rake (0.9.2, 0.8.7).
我有一篇关于此的博文,您已经激活了 Rake 0.9.2< /em>。有两种方法可以做到这一点:
仅使用旧版本的 Rake:
使用
$ gem list
查看当前的 Rake 版本。查看您拥有哪些版本的 Rake,并将其全部删除(0.8.7
除外)。您可以使用gem uninstall rake -v=0.9.1
或您需要删除的任何版本来删除 gem。或者只在 Rake 文件中添加一行代码:
除非您必须使用旧版本的 Rake,否则将此行
require 'rake/dsl_definition'
添加到 Rails 应用程序的 Rakefile 会更容易。I have a blog post about this, You have already activated Rake 0.9.2. There are two ways to do this:
Only use the older version of Rake:
Check out your current Rake versions with
$ gem list
. See which versions of Rake you have and remove them all except for0.8.7
. You can remove the gems withgem uninstall rake -v=0.9.1
or whatever version you need to remove.Or just add a one liner to your Rake file:
Unless you have to use the older version of Rake it is easier to add this line
require 'rake/dsl_definition'
to your Rails's app Rakefile.我之前用它来解决这个问题,没有删除任何宝石。此方法将强制您的应用程序使用比 0.9+ 更稳定的 Rake 0.8.7。您必须在指定要使用的 Rake 版本后运行
bundle update rake
命令,以便您的gemfile.lock
文件与您的 gem 文件同步(如果您跳过此步骤 Heroku 将不让你推送你的代码!)在你的 gem 文件中指定要使用的 Rake 版本:
然后执行:
如果这仍然不适合你,那么执行:
I used this to solve this very problem earlier without deleting any gems. This method will force your app to use Rake 0.8.7 which is more stable than 0.9+. You must run
bundle update rake
command after specifying the version of Rake to use so yourgemfile.lock
file is in sync with your gem file (if you skip this step Heroku will not let you push your code!)In your gem file specify the version of Rake to use:
Then do:
If this still isn't working for you, then do:
与rich的答案一样(解决这个问题而不删除任何 gem),但对步骤 1. 进行更正,并执行一些附加步骤:
在 gem 文件中指定:
bundle install
(Bundler 文档说在更改 gem 文件后始终“bundle install”)git commit -am “通过在中指定 rake 0.8.7 修复了 heroku rake 问题Gemfile"
git push heroku
heroku rake db:migrate
我得到了同样的错误,没有步骤3 和4.
As with rich's answer (solving this problem without deleting any gems), but with a correction to your step 1., and a few additional steps:
In the gem file specify:
bundle install
(Bundler documentation say to always 'bundle install' after changing your gem file)git commit -am "Fixed heroku rake problem by specifying rake 0.8.7 in Gemfile"
git push heroku
heroku rake db:migrate
I got the same error without steps 3 and 4.