2016-09-25 122 views
0

UPDATE:即使我完全從我的GemfileGemfile.lock去除sqlite3寶石,它仍然被安裝在Heroku。的Rails:無法部署到Heroku的

我想部署我的Rails應用的Heroku,甚至壽我跟着指示,我得到了臭名昭著的sqlite3的錯誤:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 
remote: 
remote:  /tmp/build_dfa00c2b50bad4da069069454f39d2b2/vendor/ruby-2.2.4/bin/ruby -r ./siteconf20160925-219-11i619z.rb extconf.rb 
remote:  checking for sqlite3.h... no 
remote:  sqlite3.h is missing. Try 'port install sqlite3 +universal', 
remote:  'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' 
remote:  and check your shared library search path (the 
remote:  location where your sqlite3 shared library is located). 
remote:  *** extconf.rb failed *** 
remote:  Could not create Makefile due to some reason, probably lack of necessary 
remote:  libraries and/or headers. Check the mkmf.log file for more details. You may 
remote:  need configuration options. 
remote: 
remote:  Provided configuration options: 
remote:  --with-opt-dir 
remote:  --without-opt-dir 
remote:  --with-opt-include 
remote:  --without-opt-include=${opt-dir}/include 
remote:  --with-opt-lib 
remote:  --without-opt-lib=${opt-dir}/lib 
remote:  --with-make-prog 
remote:  --without-make-prog 
remote:  --srcdir=. 
remote:  --curdir 
remote:  --ruby=/tmp/build_dfa00c2b50bad4da069069454f39d2b2/vendor/ruby-2.2.4/bin/$(RUBY_BASE_NAME) 
remote:  --with-sqlite3-dir 
remote:  --without-sqlite3-dir 
remote:  --with-sqlite3-include 
remote:  --without-sqlite3-include=${sqlite3-dir}/include 
remote:  --with-sqlite3-lib 
remote:  --without-sqlite3-lib=${sqlite3-dir}/lib 
remote: 
remote:  extconf failed, exit code 1 
remote: 
remote:  Gem files will remain installed in /tmp/build_dfa00c2b50bad4da069069454f39d2b2/vendor/bundle/ruby/2.2.0/gems/sqlite3-1.3.11 for inspection. 
remote:  Results logged to /tmp/build_dfa00c2b50bad4da069069454f39d2b2/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0-static/sqlite3-1.3.11/gem_make.out 
remote:  Installing websocket-driver 0.6.4 with native extensions 
remote:  Installing rack-test 0.6.3 
remote:  Installing nokogiri 1.6.8 with native extensions 
remote:  Installing warden 1.2.6 
remote:  Installing sprockets 3.7.0 
remote:  Installing mime-types 3.1 
remote:  Installing coffee-script 2.4.1 
remote:  Installing uglifier 3.0.2 
remote:  Installing turbolinks 5.0.1 
remote:  Installing less 2.6.0 
remote:  Installing activesupport 5.0.0.1 
remote:  An error occurred while installing sqlite3 (1.3.11), and Bundler cannot 
remote:  continue. 
remote:  Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling. 
remote: ! 
remote: !  Failed to install gems via Bundler. 
remote: ! 
remote: !  Detected sqlite3 gem which is not supported on Heroku. 
remote: !  https://devcenter.heroku.com/articles/sqlite3 
remote: ! 
remote: !  Push rejected, failed to compile Ruby app. 
remote: 
remote: !  Push failed 

的問題是,我有完全一樣的GemfileGemfile.lock我曾與一個類似的項目,併成功部署到Heroku。

這裏是我的Gemfile

source 'https://rubygems.org' 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '~> 5.0.0', '>= 5.0.0.1' 
# Use Puma as the app server 
gem 'puma', '~> 3.0' 
# 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.2' 
# 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 navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 
gem 'turbolinks', '~> 5' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.5' 
# Use Redis adapter to run Action Cable in production 
# gem 'redis', '~> 3.0' 
# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 
gem 'shotgun', '~> 0.9.2' 
group :development, :test do 
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
    gem 'byebug', platform: :mri 
end 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 
    gem 'web-console' 
    gem 'listen', '~> 3.0.5' 
    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 
    gem 'spring' 
    gem 'spring-watcher-listen', '~> 2.0.0' 
    # Use sqlite3 as the database for Active Record 
    gem 'sqlite3' 
end 

group :production do 
    gem 'pg' 
end 
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' 
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 
gem 'font-awesome-rails' 
gem 'simple_form' 
gem 'devise' 

而且我Gemfile.lock,這的確包含sqlite3寶石:

GIT 
remote: git://github.com/seyhunak/twitter-bootstrap-rails.git 
    revision: d3776ddd0b89d28fdebfd6e1c1541348cc90e5cc 
    specs: 
    twitter-bootstrap-rails (3.2.2) 
     actionpack (>= 3.1) 
     execjs (>= 2.2.2, >= 2.2) 
     less-rails (>= 2.5.0) 
     railties (>= 3.1) 

GEM 
    remote: https://rubygems.org/ 
    specs: 
    actioncable (5.0.0.1) 
     actionpack (= 5.0.0.1) 
     nio4r (~> 1.2) 
     websocket-driver (~> 0.6.1) 
    actionmailer (5.0.0.1) 
     actionpack (= 5.0.0.1) 
     actionview (= 5.0.0.1) 
     activejob (= 5.0.0.1) 
     mail (~> 2.5, >= 2.5.4) 
     rails-dom-testing (~> 2.0) 
    actionpack (5.0.0.1) 
     actionview (= 5.0.0.1) 
     activesupport (= 5.0.0.1) 
     rack (~> 2.0) 
     rack-test (~> 0.6.3) 
     rails-dom-testing (~> 2.0) 
     rails-html-sanitizer (~> 1.0, >= 1.0.2) 
    actionview (5.0.0.1) 
     activesupport (= 5.0.0.1) 
     builder (~> 3.1) 
     erubis (~> 2.7.0) 
     rails-dom-testing (~> 2.0) 
     rails-html-sanitizer (~> 1.0, >= 1.0.2) 
    activejob (5.0.0.1) 
     activesupport (= 5.0.0.1) 
     globalid (>= 0.3.6) 
    activemodel (5.0.0.1) 
     activesupport (= 5.0.0.1) 
    activerecord (5.0.0.1) 
     activemodel (= 5.0.0.1) 
     activesupport (= 5.0.0.1) 
     arel (~> 7.0) 
    activesupport (5.0.0.1) 
     concurrent-ruby (~> 1.0, >= 1.0.2) 
     i18n (~> 0.7) 
     minitest (~> 5.1) 
     tzinfo (~> 1.1) 
    arel (7.1.2) 
    bcrypt (3.1.11) 
    builder (3.2.2) 
    byebug (9.0.5) 
    coffee-rails (4.2.1) 
     coffee-script (>= 2.2.0) 
     railties (>= 4.0.0, < 5.2.x) 
    coffee-script (2.4.1) 
     coffee-script-source 
     execjs 
    coffee-script-source (1.10.0) 
    commonjs (0.2.7) 
    concurrent-ruby (1.0.2) 
    debug_inspector (0.0.2) 
    devise (4.2.0) 
     bcrypt (~> 3.0) 
     orm_adapter (~> 0.1) 
     railties (>= 4.1.0, < 5.1) 
     responders 
     warden (~> 1.2.3) 
    erubis (2.7.0) 
    execjs (2.7.0) 
    ffi (1.9.14) 
    font-awesome-rails (4.6.3.1) 
     railties (>= 3.2, < 5.1) 
    geocoder (1.4.0) 
    globalid (0.3.7) 
     activesupport (>= 4.1.0) 
    gravatarify (3.0.0) 
    i18n (0.7.0) 
    jbuilder (2.6.0) 
     activesupport (>= 3.0.0, < 5.1) 
     multi_json (~> 1.2) 
    jquery-rails (4.2.1) 
     rails-dom-testing (>= 1, < 3) 
     railties (>= 4.2.0) 
     thor (>= 0.14, < 2.0) 
    less (2.6.0) 
     commonjs (~> 0.2.7) 
    less-rails (2.7.1) 
     actionpack (>= 4.0) 
     less (~> 2.6.0) 
     sprockets (> 2, < 4) 
     tilt 
    listen (3.0.8) 
     rb-fsevent (~> 0.9, >= 0.9.4) 
     rb-inotify (~> 0.9, >= 0.9.7) 
    loofah (2.0.3) 
     nokogiri (>= 1.5.9) 
    mail (2.6.4) 
     mime-types (>= 1.16, < 4) 
    method_source (0.8.2) 
    mime-types (3.1) 
     mime-types-data (~> 3.2015) 
    mime-types-data (3.2016.0521) 
    mini_portile2 (2.1.0) 
    minitest (5.9.0) 
    multi_json (1.12.1) 
    nio4r (1.2.1) 
    nokogiri (1.6.8) 
     mini_portile2 (~> 2.1.0) 
     pkg-config (~> 1.1.7) 
    orm_adapter (0.5.0) 
    pg (0.19.0) 
    pkg-config (1.1.7) 
    puma (3.6.0) 
    rack (2.0.1) 
    rack-test (0.6.3) 
     rack (>= 1.0) 
    rails (5.0.0.1) 
     actioncable (= 5.0.0.1) 
     actionmailer (= 5.0.0.1) 
     actionpack (= 5.0.0.1) 
     actionview (= 5.0.0.1) 
     activejob (= 5.0.0.1) 
     activemodel (= 5.0.0.1) 
     activerecord (= 5.0.0.1) 
     activesupport (= 5.0.0.1) 
     bundler (>= 1.3.0, < 2.0) 
     railties (= 5.0.0.1) 
     sprockets-rails (>= 2.0.0) 
    rails-dom-testing (2.0.1) 
     activesupport (>= 4.2.0, < 6.0) 
     nokogiri (~> 1.6.0) 
    rails-html-sanitizer (1.0.3) 
     loofah (~> 2.0) 
    railties (5.0.0.1) 
     actionpack (= 5.0.0.1) 
     activesupport (= 5.0.0.1) 
     method_source 
     rake (>= 0.8.7) 
     thor (>= 0.18.1, < 2.0) 
    rake (11.3.0) 
    rb-fsevent (0.9.7) 
    rb-inotify (0.9.7) 
     ffi (>= 0.5.0) 
    responders (2.3.0) 
     railties (>= 4.2.0, < 5.1) 
    sass (3.4.22) 
    sass-rails (5.0.6) 
     railties (>= 4.0.0, < 6) 
     sass (~> 3.1) 
     sprockets (>= 2.8, < 4.0) 
     sprockets-rails (>= 2.0, < 4.0) 
     tilt (>= 1.1, < 3) 
    simple_form (3.3.1) 
     actionpack (> 4, < 5.1) 
     activemodel (> 4, < 5.1) 
    spring (1.7.2) 
    spring-watcher-listen (2.0.0) 
     listen (>= 2.7, < 4.0) 
     spring (~> 1.2) 
    sprockets (3.7.0) 
     concurrent-ruby (~> 1.0) 
     rack (> 1, < 3) 
    sprockets-rails (3.2.0) 
     actionpack (>= 4.0) 
     activesupport (>= 4.0) 
     sprockets (>= 3.0.0) 
    sqlite3 (1.3.11) 
    thor (0.19.1) 
    thread_safe (0.3.5) 
    tilt (2.0.5) 
    turbolinks (5.0.1) 
     turbolinks-source (~> 5) 
    turbolinks-source (5.0.0) 
    tzinfo (1.2.2) 
     thread_safe (~> 0.1) 
    uglifier (3.0.2) 
     execjs (>= 0.3.0, < 3) 
    warden (1.2.6) 
     rack (>= 1.0) 
    web-console (3.3.1) 
     actionview (>= 5.0) 
     activemodel (>= 5.0) 
     debug_inspector 
     railties (>= 5.0) 
    websocket-driver (0.6.4) 
     websocket-extensions (>= 0.1.0) 
    websocket-extensions (0.1.2) 

PLATFORMS 
    ruby 

DEPENDENCIES 
    byebug 
    coffee-rails (~> 4.2) 
    devise 
    font-awesome-rails 
    geocoder 
    gravatarify (~> 3.0.0) 
    jbuilder (~> 2.5) 
    jquery-rails 
    listen (~> 3.0.5) 
    pg 
    puma (~> 3.0) 
    rails (~> 5.0.0, >= 5.0.0.1) 
    sass-rails (~> 5.0) 
    simple_form 
    spring 
    spring-watcher-listen (~> 2.0.0) 
    sqlite3 
    turbolinks (~> 5) 
    twitter-bootstrap-rails! 
    tzinfo-data 
    uglifier (>= 1.3.0) 
    web-console 

BUNDLED WITH 
    1.13.1 

感謝您的幫助!

+0

也許你應該在heroku上使用sqlite?這個錯誤只是證明=) – Aleksey

+0

@Aleksey Heroku不支持'sqlite3',因此我使用'pg'gem – noloman

+0

我想到了。謝謝,但我從來沒有使用sqlite3 – Aleksey

回答

1

不幸的是,我試圖推到Heroku的沒有犯下我的變化。感謝大家的幫助!

1

sqlite 3 gem不能安裝在heroku中。這是一個示例數據庫,它是Rails默認的。在生產的情況下,你將不得不使用一些先進的數據庫。請查看此鏈接以獲取更多信息https://devcenter.heroku.com/articles/sqlite3

+0

我已經閱讀過,而我無法弄清楚的部分是'https://devcenter.heroku.com/articles/sqlite3#getting-a-sqlite-error-even-though這是不是在gemfile' – noloman

+0

你可以請捆綁本地安裝你的寶石,然後推你的gemfile.lock到heroku? –

+0

我這樣做了,但結果是一樣的 – noloman

0

Heroku爲您的應用程序提供Postgresql數據庫作爲服務。閱讀here,爲什麼在生產模式下使用sqlite3並不是一個好主意。

所以,你需要你的Gemfile改變這樣的事情:

group :production do 
    # postgresql 
    gem 'pg' 
    # enabling features such as static asset serving and logging on Heroku 
    gem 'rails_12factor' 
end 

group :development, :test do 
    # SQLite3 Database 
    gem 'sqlite3' 
    ... 
end 
+0

我已經試過了,如果你看到'Gemfile'我有'pg'gem在生產環境中,而'sqlite3'gem在發展 – noloman