【问题标题】:git push heroku master: Error occurred while installing sqlite3git push heroku master:安装 sqlite3 时出错
【发布时间】:2015-07-13 04:22:03
【问题描述】:

这个问题我快疯了。

我是 Heroku 的新手,今天我正在尝试部署我的应用程序,但我做不到。我可以构建一次,但它给了我一个“内部服务器错误”。

错误:

当我运行git push heroku master 时,提交后,它返回:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile
-----> Installing dependencies using 1.7.12
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
       Fetching gem metadata from https://rubygems.org/.........
       Resolving dependencies...
       Using json 1.8.2
       Using i18n 0.7.0
       ...
       Using sass-rails 5.0.3
       Using turbolinks 2.5.3
       Installing bootstrap-sass 3.2.0.2
       Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
       /tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/ruby-2.0.0/bin/ruby extconf.rb
       checking for sqlite3.h... no
       sqlite3.h is missing. Try 'port install sqlite3 +universal',
       'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
       and check your shared library search path (the
       location where your sqlite3 shared library is located).
       *** extconf.rb failed ***
       Could not create Makefile due to some reason, probably lack of necessary
       libraries and/or headers.  Check the mkmf.log file for more details.  You may
       need configuration options.
       Provided configuration options:
       --with-opt-dir
       --without-opt-dir
       --with-opt-include
       --without-opt-include=${opt-dir}/include
       --with-opt-lib
       --without-opt-lib=${opt-dir}/lib
       --with-make-prog
       --without-make-prog
       --srcdir=.
       --curdir
       --ruby=/tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/ruby-2.0.0/bin/ruby
       --with-sqlite3-dir
       --without-sqlite3-dir
       --with-sqlite3-include
       --without-sqlite3-include=${sqlite3-dir}/include
       --with-sqlite3-lib
       --without-sqlite3-lib=${sqlite3-dir}/
       Gem files will remain installed in /tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10 for inspection.
       Results logged to /tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10/ext/sqlite3/gem_make.out
       An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
       continue.
       Make sure that `gem install sqlite3 -v '1.3.10'` succeeds before bundling.
       Bundler Output: Fetching gem metadata from https://rubygems.org/.........
       Resolving dependencies...
       Using json 1.8.2
       Using i18n 0.7.0
       ...
       Using sass-rails 5.0.3
       Using turbolinks 2.5.3
       Installing bootstrap-sass 3.2.0.2
       
       Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
       
       /tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/ruby-2.0.0/bin/ruby extconf.rb
       checking for sqlite3.h... no
       sqlite3.h is missing. Try 'port install sqlite3 +universal',
       'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
       and check your shared library search path (the
       location where your sqlite3 shared library is located).
       *** extconf.rb failed ***
       Could not create Makefile due to some reason, probably lack of necessary
       libraries and/or headers.  Check the mkmf.log file for more details.  You may
       need configuration options.
       
       Provided configuration options:
       --with-opt-dir
       --without-opt-dir
       --with-opt-include
       --without-opt-include=${opt-dir}/include
       --with-opt-lib
       --without-opt-lib=${opt-dir}/lib
       --with-make-prog
       --without-make-prog
       --srcdir=.
       --curdir
       --ruby=/tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/ruby-2.0.0/bin/ruby
       --with-sqlite3-dir
       --without-sqlite3-dir
       --with-sqlite3-include
       --without-sqlite3-include=${sqlite3-dir}/include
       --with-sqlite3-lib
       --without-sqlite3-lib=${sqlite3-dir}/
       
       Gem files will remain installed in /tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10 for inspection.
       Results logged to /tmp/build_4e3945a34652ba20ca13b13d160a9dd7/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.10/ext/sqlite3/gem_make.out
       An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
       continue.
       Make sure that `gem install sqlite3 -v '1.3.10'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !     
 !     Detected sqlite3 gem which is not supported on Heroku.
 !     https://devcenter.heroku.com/articles/sqlite3
 !
 !     Push rejected, failed to compile Ruby app

如果这是一个简单的错误,请原谅我。但这让我很头疼。

【问题讨论】:

  • 阅读 heroku 文档。你不能在heroku上运行sqlite。必须是 postgres。
  • 我的网站没有bd。我不需要 pg 或 sqlite3,但我得到同样的错误@Gene [stackoverflow.com/questions/30019003/…
  • @suslov 有问题。我是否需要提交所做的每项更改?感谢您的宝贵时间!
  • @DavidM:好吧,只有当你想要推送不同的东西时。
  • 您的 gem 文件中是否只有开发/测试块中的 sqlite3 gem?

标签: ruby-on-rails ruby-on-rails-4 heroku sqlite


【解决方案1】:

已解决

错误:我不知道我必须提交更改。

  1. git commit -am "注释行"
  2. git 推送
  3. git push heroku master

就是这样。谢谢,@suslov

【讨论】:

    【解决方案2】:

    如您的错误代码所述,Heroku 不支持 sqlite3 gem:

    检测到 Heroku 不支持的 sqlite3 gem。

    所以你不能使用 SQLite 数据库,应该从你的 Gemfile 删除这一行:

    gem 'sqlite3'
    

    Instead Heroku supports pg gem to run your application on PostgreSQL RDBMS 所以你应该将以下行添加到Gemfile:

    gem 'pg'
    

    然后运行bundle install

    然后在 config/database.yml 中更改您的 RDBMS 设置:

    default: &default
      adapter: postgresql
      pool: 5
      timeout: 5000
    
    development:
      database: db/development
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      <<: *default
      database: db/test
    
    production:
      <<: *default
      database: db/production
    

    之后你应该commit所有更改并最终运行:

    git push heroku master
    

    【讨论】:

      【解决方案3】:

      您是否尝试从本地存储库推送到托管?在你推送之前,我认为你必须通过键入来建立关系。

      $ git remote add [alias] [url] 如果您使用 git clone 获得了存储库,则输入 $git push heroku master 并再次输入 $ git push 而无需 heroku master。我希望这能回答你的问题。

      【讨论】:

      • 是的,我正在尝试从我的 HDD 推送到 Heroku。我在 10 小时前添加了我的存储库,我可以在 6 小时前推送,但现在,我不能。我尝试使用git remote add,但不起作用。我得到了同样的错误。 mysql3,但是mysql3不在Gemfile中。感谢您的时间 ! :)
      【解决方案4】:

      我可以帮你:

      group :production do
        gem 'pg'
      end
      

      【讨论】:

      • 虽然此源代码可以提供答案,但几句话的解释将使当前和未来的读者受益。
      • 您不能在 Heroku 上使用 sqlite3 - 这是错误的原因。 Heroku 使用 Postgres DB。
      • 在捆绑之前确保gem install sqlite3 -v '1.3.10'成功。即使添加了上面的行,我也会得到同样的错误。是的,我已经提交并推送了更改
      猜你喜欢
      • 1970-01-01
      • 2014-02-01
      • 2013-02-03
      • 2016-12-26
      • 1970-01-01
      • 2021-03-30
      • 2011-05-23
      • 2016-02-19
      • 1970-01-01
      相关资源
      最近更新 更多