简体   繁体   English

Rails应用程序不会部署到heroku

[英]rails app wont deploy to heroku

I am trying to push my app to heroku but i keep getting errors. 我正在尝试将我的应用程序推送到heroku,但我不断收到错误消息。 I see that heroku doesnt support sqlite3 and I removed it from the gem file, then bundled. 我看到heroku不支持sqlite3,我从gem文件中将其删除,然后捆绑了。 My database.yml file is using postgresql. 我的database.yml文件使用的是postgresql。 Maybe something else is trying to use sqlite? 也许还有其他尝试使用sqlite吗? How do I fix this issue? 如何解决此问题? Below is the log from heroku after the following command. 以下是在执行以下命令后来自heroku的日志。

$git push heroku master

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.2.4
-----> Installing dependencies using bundler 1.11.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/...........
       Fetching version metadata from https://rubygems.org/...
       Fetching dependency metadata from https://rubygems.org/..
       Using rake 10.4.2
       Installing i18n 0.7.0
       Installing minitest 5.8.0
       Installing json 1.8.3 with native extensions
       Installing thread_safe 0.3.5
       Installing builder 3.2.2
       Installing erubis 2.7.0
       Installing mini_portile 0.6.2
       Installing rack 1.6.4
       Installing arel 6.0.3
       Installing coffee-script-source 1.9.1.1
       Installing mime-types 2.6.1
       Installing thor 0.19.1
       Installing execjs 2.6.0
       Using bundler 1.11.2
       Using rdoc 4.2.0
       Installing multi_json 1.11.2
       Installing tilt 1.4.1
       Installing sass 3.4.18
       Installing sqlite3 1.3.10 with native extensions
       Installing tzinfo 1.2.2
       Installing nokogiri 1.6.6.2 with native extensions
       Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
       /tmp/build_c19da7ca03c7dd80010af978d40d9316/vendor/ruby-2.2.4/bin/ruby -r ./siteconf20161013-219-al82rl.rb 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_c19da7ca03c7dd80010af978d40d9316/vendor/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
       --with-sqlite3-dir
       --without-sqlite3-dir
       --with-sqlite3-include
       --without-sqlite3-include=${sqlite3-dir}/include
       --with-sqlite3-lib
       --without-sqlite3-lib=${sqlite3-dir}/lib
       extconf failed, exit code 1
       Gem files will remain installed in /tmp/build_c19da7ca03c7dd80010af978d40d9316/vendor/bundle/ruby/2.2.0/gems/sqlite3-1.3.10 for inspection.
       Results logged to /tmp/build_c19da7ca03c7dd80010af978d40d9316/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0-static/sqlite3-1.3.10/gem_make.out
       Installing rack-test 0.6.3
       Installing sprockets 3.3.3
       Installing mail 2.6.3
       Installing coffee-script 2.4.1
       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/...........
       Fetching version metadata from https://rubygems.org/...
       Fetching dependency metadata from https://rubygems.org/..
       Using rake 10.4.2
       Installing i18n 0.7.0
       Installing minitest 5.8.0
       Installing json 1.8.3 with native extensions
       Installing thread_safe 0.3.5
       Installing builder 3.2.2
       Installing erubis 2.7.0
       Installing mini_portile 0.6.2
       Installing rack 1.6.4
       Installing arel 6.0.3
       Installing coffee-script-source 1.9.1.1
       Installing mime-types 2.6.1
       Installing thor 0.19.1
       Installing execjs 2.6.0
       Using bundler 1.11.2
       Using rdoc 4.2.0
       Installing multi_json 1.11.2
       Installing tilt 1.4.1
       Installing sass 3.4.18
       Installing sqlite3 1.3.10 with native extensions
       Installing tzinfo 1.2.2
       Installing nokogiri 1.6.6.2 with native extensions

       Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

       /tmp/build_c19da7ca03c7dd80010af978d40d9316/vendor/ruby-2.2.4/bin/ruby -r ./siteconf20161013-219-al82rl.rb 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_c19da7ca03c7dd80010af978d40d9316/vendor/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
       --with-sqlite3-dir
       --without-sqlite3-dir
       --with-sqlite3-include
       --without-sqlite3-include=${sqlite3-dir}/include
       --with-sqlite3-lib
       --without-sqlite3-lib=${sqlite3-dir}/lib

       extconf failed, exit code 1

       Gem files will remain installed in /tmp/build_c19da7ca03c7dd80010af978d40d9316/vendor/bundle/ruby/2.2.0/gems/sqlite3-1.3.10 for inspection.
       Results logged to /tmp/build_c19da7ca03c7dd80010af978d40d9316/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0-static/sqlite3-1.3.10/gem_make.out
       Installing rack-test 0.6.3
       Installing sprockets 3.3.3
       Installing mail 2.6.3
       Installing coffee-script 2.4.1
       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.
 !     Push failed

Here is my database.yml file 这是我的database.yml文件

development:
  adapter: postgresql
  encoding: utf8
  database: db/development
  host: localhost
  pool: 5
  timeout: 5000
  username: sfinley
  password: password

test:
  adapter: postgresql
  encoding: utf8
  database: db/test
  pool: 5
  timeout: 5000
  username: sfinley
  password: password

production:
  adapter: postgresql
  encoding: utf8
  database: db/production
  pool: 5
  timeout: 5000
  username: sfinley
  password: password

Here is my gem file 这是我的宝石文件

source 'https://rubygems.org'
# http://ifyouseeit.org/blog/2013/08/07/switch-db-from-sqlite3-to-postgres-in-rails-app/
gem 'pg'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

I have answered this question before in a similar post . 我之前在类似的帖子中已经回答了这个问题。 Doing a simple search would have gotten you the answer instead of asking right away. 进行简单的搜索就可以为您找到答案,而不必立即询问。 Anyways heres the solution. 无论如何,这就是解决方案。

Just do this in your Gemfile 只需在您的Gemfile中执行此操作

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

and shift your sqlite3 gem to 并将sqlite3宝石移至

group :development, :test do
  gem 'sqlite3'
end

run bundle install --without production and you should be good to go. 运行bundle install --without production ,您应该一切顺利。 Remember to push your new code to git before trying to push to Heroku. 在尝试推送到Heroku之前,请记住将新代码推送到git。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM