【问题标题】:Heroku error when running heroku rake db:migrate运行 heroku rake db:migrate 时出现 Heroku 错误
【发布时间】:2011-12-20 12:29:45
【问题描述】:

当我尝试运行时

heroku rake db:migrate

我收到以下错误:

rake 中止! 请安装 postgresql 适配器:gem install activerecord-postgresql-adapter(pg 不是捆绑包的一部分。将其添加到 Gemfile。) 任务:TOP => db:migrate => db:load_config (通过使用 --trace 运行任务查看完整跟踪)

这是我的 Gemfile 的样子:

group :production do
  gem 'pg'
end

group :development, :test do
  gem 'turn', '0.8.2', :require => false
  gem 'sqlite3', '1.3.5'
end

所以我将“pg”添加到 Gemfile,但它仍然抱怨。我有点绝望,因为我不知道下一步该怎么做..?

更新 命令heroku run rake db:migrate 会导致同样的错误。

这是我的 Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.3'

group :production do gem 'pg', '0.12.0' end

group :development, :test do # Pretty printed test output gem 'turn', '0.8.2', :require => false gem 'sqlite3', '1.3.5' end

# Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git'

# Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.1.5' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' end

gem 'jquery-rails'

# To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server # gem 'unicorn'

# Deploy with Capistrano # gem 'capistrano'

# To use debugger # gem 'ruby-debug19', :require => 'ruby-debug'

非常感谢您的帮助!

更新 2

这是我的 Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.1.3)
      actionpack (= 3.1.3)
      mail (~> 2.3.0)
    actionpack (3.1.3)
      activemodel (= 3.1.3)
      activesupport (= 3.1.3)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      i18n (~> 0.6)
      rack (~> 1.3.5)
      rack-cache (~> 1.1)
      rack-mount (~> 0.8.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.0.3)
    activemodel (3.1.3)
      activesupport (= 3.1.3)
      builder (~> 3.0.0)
      i18n (~> 0.6)
    activerecord (3.1.3)
      activemodel (= 3.1.3)
      activesupport (= 3.1.3)
      arel (~> 2.2.1)
      tzinfo (~> 0.3.29)
    activeresource (3.1.3)
      activemodel (= 3.1.3)
      activesupport (= 3.1.3)
    activesupport (3.1.3)
      multi_json (~> 1.0)
    ansi (1.4.1)
    arel (2.2.1)
    builder (3.0.0)
    coffee-rails (3.1.1)
      coffee-script (>= 2.2.0)
      railties (~> 3.1.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.1.3)
    erubis (2.7.0)
    execjs (1.2.12)
      multi_json (~> 1.0)
    hike (1.2.1)
    i18n (0.6.0)
    jquery-rails (1.0.19)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.6.3)
    mail (2.3.0)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.17.2)
    multi_json (1.0.4)
    pg (0.12.0)
      rake-compiler (~> 0.7)
    polyglot (0.3.3)
    rack (1.3.5)
    rack-cache (1.1)
      rack (>= 0.4)
    rack-mount (0.8.3)
      rack (>= 1.0.0)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.1.3)
      actionmailer (= 3.1.3)
      actionpack (= 3.1.3)
      activerecord (= 3.1.3)
      activeresource (= 3.1.3)
      activesupport (= 3.1.3)
      bundler (~> 1.0)
      railties (= 3.1.3)
    railties (3.1.3)
      actionpack (= 3.1.3)
      activesupport (= 3.1.3)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2.2)
    rake-compiler (0.7.9)
      rake
    rdoc (3.12)
      json (~> 1.4)
    sass (3.1.12)
    sass-rails (3.1.5)
      actionpack (~> 3.1.0)
      railties (~> 3.1.0)
      sass (~> 3.1.10)
      tilt (~> 1.3.2)
    sprockets (2.0.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.5)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    turn (0.8.2)
      ansi (>= 1.2.2)
    tzinfo (0.3.31)
    uglifier (1.2.0)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)

PLATFORMS
  ruby

DEPENDENCIES
  coffee-rails (~> 3.1.1)
  jquery-rails
  pg (= 0.12.0)
  rails (= 3.1.3)
  sass-rails (~> 3.1.5)
  sqlite3 (= 1.3.5)
  turn (= 0.8.2)
  uglifier (>= 1.0.3)

【问题讨论】:

  • 在再次向上推之前,您是否运行了bundle install --without production 并检查了生成的 Gemfile.lock?
  • 你签入你的 gemfile.lock 了吗?我敢打赌这是以前的问题。现在您可能需要运行“捆绑安装”,因为由于某种原因,您的 gemfile.lock 与 heroku 认为的不匹配。
  • 是的,我运行了那个命令。但是由于我对 RoR 还很陌生,所以我不确定要注意什么。我在规格下列出了pg,在依赖项下也列出了列表。如何检查 Gemfile.lock 是否有错误?当我输入 bundle install 时,我没有看到 Using pg (0.12.0) 行 - 这有点奇怪,不是吗?
  • 看起来和这个一样,只是你没有做heroku create --stack cedar:stackoverflow.com/questions/7492636/…
  • 我运行了该命令,但无济于事。我不知道还能做什么......

标签: ruby-on-rails postgresql heroku


【解决方案1】:

如果您在 Cedar 上,则需要运行 heroku run rake db:migrate,尽管听起来并非如此。如果您正在运行 rails 3 或 >,那么您应该使用 cedar 堆栈。

您也可以尝试将gem 'pg', " ~> 0.12.0" 添加到您的gem 文件并再次运行bundler (bundle install),这应该将pg 放入您的Gemfile.lock(查找类似:pg (0.12.0)

如果这不起作用,可以告诉我们您的环境,也许可以粘贴 heroku --trace 日志?

【讨论】:

  • 谢谢。我一回家就试试。只有一个问题:雪松到底是什么?
  • 我将我的 Gemfile 发布到原始帖子。命令heroku run rake db:migrate 不幸导致同样的错误。
  • 没问题。希望这会奏效。 Cedar Stack 是为 rails 3 或更高版本正确配置的 heroku Stack。你可以阅读更多关于它的信息here
  • 你在 gemfile.lock 中看到 pg (0.12.0) 了吗?
  • 我在原始帖子中发布了我的 Gemfile.lock。顺便说一句,我在 Ubuntu 10.04 上运行
【解决方案2】:

尝试将其添加到您的 gemfile 中

gem 'therubyracer'

捆绑它,然后运行所有必要的命令。

【讨论】:

  • 不抱歉,这没有帮助我在 gemfile 中添加了该行,将其捆绑并再次运行 heroku rake db:migrate - 与以前相同的错误。我在 Ubuntu 10.04 上运行,仅供参考。
猜你喜欢
  • 2013-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-21
  • 2012-09-06
  • 1970-01-01
  • 2017-04-16
相关资源
最近更新 更多