【问题标题】:Heroku is trying to install sqlite3 gem even it not being in the GemfileHeroku 正在尝试安装 sqlite3 gem,即使它不在 Gemfile 中
【发布时间】:2011-12-08 20:20:04
【问题描述】:

我第一次尝试在 Heroku 上部署 Rails 3.1 应用程序。我将它设置为 Cedar 堆栈,删除了 sqlite3 gem,但是当我将代码推送到 Heroku 时,出现此错误:

-----> 使用 Bundler 版本 1.1.rc 安装依赖项 运行: bundle install --without development:test --path vendor/bundle --deployment 正在从 http://rubygems.org/....... 获取 gem 元数据 (...)

安装导轨 (3.1.0) 使用本机扩展安装 sqlite3 (1.3.4) 不幸的是,发生了致命错误。请将此错误报告给 Bundler 问题跟踪器位于 https://github.com/carlhuda/bundler/issues 以便我们修复它。 谢谢! /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions':错误:无法构建 gem native 延期。 (Gem::Installer::ExtensionBuildError) /usr/local/bin/ruby extconf.rb 检查 sqlite3.h... 否

我不知道为什么 bundle install 试图安装 sqlite3。看看我的 Gemfile 和 Gemfile.lock:

宝石文件

source 'http://rubygems.org'

gem 'rails', '3.1.0'

gem 'json'
gem 'pg'
gem 'thin'

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

gem 'jquery-rails'

Gemfile.lock

GEM   remote: http://rubygems.org/   specs:
    actionmailer (3.1.0)
      actionpack (= 3.1.0)
      mail (~> 2.3.0)
    actionpack (3.1.0)
      activemodel (= 3.1.0)
      activesupport (= 3.1.0)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      i18n (~> 0.6)
      rack (~> 1.3.2)
      rack-cache (~> 1.0.3)
      rack-mount (~> 0.8.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.0.0)
    activemodel (3.1.0)
      activesupport (= 3.1.0)
      bcrypt-ruby (~> 3.0.0)
      builder (~> 3.0.0)
      i18n (~> 0.6)
    activerecord (3.1.0)
      activemodel (= 3.1.0)
      activesupport (= 3.1.0)
      arel (~> 2.2.1)
      tzinfo (~> 0.3.29)
    activeresource (3.1.0)
      activemodel (= 3.1.0)
      activesupport (= 3.1.0)
    activesupport (3.1.0)
      multi_json (~> 1.0)
    arel (2.2.1)
    bcrypt-ruby (3.0.1)
    builder (3.0.0)
    daemons (1.1.4)
    erubis (2.7.0)
    eventmachine (0.12.10)
    execjs (1.2.9)
      multi_json (~> 1.0)
    hike (1.2.1)
    i18n (0.6.0)
    jquery-rails (1.0.14)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.6.1)
    mail (2.3.0)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    multi_json (1.0.3)
    pg (0.11.0)
    polyglot (0.3.2)
    rack (1.3.3)
    rack-cache (1.0.3)
      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.0)
      actionmailer (= 3.1.0)
      actionpack (= 3.1.0)
      activerecord (= 3.1.0)
      activeresource (= 3.1.0)
      activesupport (= 3.1.0)
      bundler (~> 1.0)
      railties (= 3.1.0)
    railties (3.1.0)
      actionpack (= 3.1.0)
      activesupport (= 3.1.0)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.6)
    rake (0.9.2)
    rdoc (3.9.4)
    sprockets (2.0.0)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    thin (1.2.11)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    uglifier (1.0.3)
      execjs (>= 0.3.0)
      multi_json (>= 1.0.2)

PLATFORMS   ruby

DEPENDENCIES   jquery-rails   json   pg   rails (= 3.1.0)   thin   uglifier

我该如何解决?

【问题讨论】:

  • 那么,投反对票的聪明人能解释一下原因吗?
  • 我遇到了同样的问题,我在本地使用 'pg' 没有问题,但 Heroku 仍在尝试安装 sqlite,因此出错。但是,我可以看到我的 gemfile.lock 中有以下内容:sqlite3 (1.3.4) sqlite3-ruby (1.3.3) sqlite3 (>= 1.3.3)。这些显然是导致问题的原因,但我无法弄清楚为什么它们仍在进入我的 gemfile.lock;无论我做多少次bundle update 或删除锁定文件并从头开始。有什么建议吗?
  • 我已经通过从我的 Gemfile 中删除 taps gem 来修复我的问题。忘了我在实际的 Gemfile 中不需要它,只是在我的 gemset 中才能使用它。删除 taps 删除了我 Gemfile.lock 中的 sqlite 依赖项。
  • 谢谢皮特,移除水龙头(在我的情况下,水龙头水龙头)对我有用:)

标签: sqlite heroku ruby-on-rails-3.1 bundler


【解决方案1】:

无需为 Heroku 卸载 sqlite3 gem 的简单解决方案:

添加到 Gemfile:

group :production do
gem 'pg', '0.17.1' #or version of pg you want
gem 'rails_12factor', '0.0.2' #Heroku static assets for image and css

检查,你有:

end 
end

在 Gemfile 中的代码末尾

保存 Gemfile 并运行 bundle install

$ bundle install --without production

提交

$ git commit -a -m "Update Gemfile.lock for Heroku"

$ git push heroku master

就是这样。您只会收到一些警告,只需修复即可。

【讨论】:

    【解决方案2】:

    当我遇到问题时,原来我忘记在bundle install 之后提交我的更改。嗬! git status 应该表示 gem 文件的未暂存更改。

    【讨论】:

      【解决方案3】:

      我有同样的问题,zoltarSpeaks 的解决方案为我解决了这个问题。我在阅读这篇文章后安装了 taps gem,这篇文章表明有必要从本地 sqlite3 推送到生产 postgresql:http://batsov.com/articles/2011/10/30/deploying-rails31-apps-on-celadon-cedar/。原来我根本不需要水龙头宝石,但这显然是问题所在。删除参考,捆绑更新,所有系统都去。

      【讨论】:

        【解决方案4】:

        尝试删除 Gemfile.lock 并运行 Bundle Install、提交和推送

        【讨论】:

        • 你在用windows做开发吗?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-10-19
        • 2012-10-04
        • 1970-01-01
        • 1970-01-01
        • 2021-05-01
        • 1970-01-01
        • 2013-12-12
        相关资源
        最近更新 更多