雷克流产了! Heroku 上未初始化的常量 Rake::DSL

发布于 2024-11-25 01:01:37 字数 659 浏览 0 评论 0原文

尝试在 Herokurake 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 技术交流群。

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

发布评论

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

评论(5

没︽人懂的悲伤 2024-12-02 01:01:37

您应该使用bundle exec 运行命令以确保获得正确的依赖项。因此,运行:

bundle exec rake db:migrate

有关更详细的帖子,请参阅 Yehuda Katz 博客文章 http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

如果您仍然遇到问题,似乎还有其他几个人也遇到同样的问题 如何修复 Heroku 上未初始化的常量 Rake::DSL 问题? 他们通过将以下内容添加到 Rakefile 中解决了这个问题:

require 'rake/dsl_definition'
require 'rake'

You should run commands with bundle exec to ensure your getting the proper dependencies. So run:

bundle exec rake db:migrate

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:

require 'rake/dsl_definition'
require 'rake'
巡山小妖精 2024-12-02 01:01:37

我在执行“heroku rake db:migrate”时遇到此错误。

/app 中:

rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
....
...
....
..
etc...

我通过添加

require 'rake/dsl_definition' 

RakeFile 来修复它,然后输入

bundle update rake
git add .
git commit -m "Change RakeFile"
git push heroku
heroku rake db:migrate

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:

rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
....
...
....
..
etc...

I fixed it by adding

require 'rake/dsl_definition' 

in RakeFile and then typed in

bundle update rake
git add .
git commit -m "Change RakeFile"
git push heroku
heroku rake db:migrate

This one solved my problem. I didn't add gem 'rake', '0.8.7' in my gem file
and my gem list shows rake (0.9.2, 0.8.7).

早乙女 2024-12-02 01:01:37

我有一篇关于此的博文,您已经激活了 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 会更容易。

require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'

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 with gem 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 linerequire 'rake/dsl_definition' to your Rails's app Rakefile.

require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
﹉夏雨初晴づ 2024-12-02 01:01:37

我之前用它来解决这个问题,没有删除任何宝石。此方法将强制您的应用程序使用比 0.9+ 更稳定的 Rake 0.8.7。您必须在指定要使用的 Rake 版本后运行 bundle update rake 命令,以便您的 gemfile.lock 文件与您的 gem 文件同步(如果您跳过此步骤 Heroku 将不让你推送你的代码!)

在你的 gem 文件中指定要使用的 Rake 版本:

"rake", "0.8.7"

然后执行:

bundle update rake

如果这仍然不适合你,那么执行:

sudo gem uninstall 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 your gemfile.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:

"rake", "0.8.7"

Then do:

bundle update rake

If this still isn't working for you, then do:

sudo gem uninstall rake
仙气飘飘 2024-12-02 01:01:37

rich的答案一样(解决这个问题而不删除任何 gem),但对步骤 1. 进行更正,并执行一些附加步骤:

  1. 在 gem 文件中指定:

    gem 'rake', '0.8.7'
    
  2. bundle install (Bundler 文档说在更改 gem 文件后始终“bundle install”)

  3. git commit -am “通过在中指定 rake 0.8.7 修复了 heroku rake 问题Gemfile"

  4. git push heroku

  5. 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:

  1. In the gem file specify:

    gem 'rake', '0.8.7'
    
  2. bundle install (Bundler documentation say to always 'bundle install' after changing your gem file)

  3. git commit -am "Fixed heroku rake problem by specifying rake 0.8.7 in Gemfile"

  4. git push heroku

  5. heroku rake db:migrate

I got the same error without steps 3 and 4.

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