Gem::Ext::BuildError: ERROR: Failed to build gem native extension - Ubuntu - ruby-on-rails

Whenever I try to bundle install on DigitalOcean Droplet - ruby-rails-postgres-nginx-unicorn
I later installed mongodb using SSH from terminal
and later when uploading the project to the /home// folder and bundle install, I get this error.
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
vinod#ruby-rails-postgres-nginx-unicorn-512mb-sgp1-01:~/dride$ bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.5.2
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using nokogiri 1.6.7.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.3
Using actionview 4.2.5.2
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.5.2
Using globalid 0.3.6
Using activejob 4.2.5.2
Using mime-types-data 3.2016.0521
Using mime-types 3.1
Using mail 2.6.4
Using actionmailer 4.2.5.2
Using activemodel 4.2.5.2
Using arel 6.0.3
Using activerecord 4.2.5.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160525-15401-ztxhbh.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling crypt_gensalt.c
compiling crypt.c
compiling crypt_blowfish.c
virtual memory exhausted: Cannot allocate memory
make: *** [crypt_blowfish.o] Error 1
make failed, exit code 2
Gem files will remain installed in /tmp/bundler20160525-15401-11lp2i/bcrypt-3.1.11/gems/bcrypt-3.1.11 for inspection.
Results logged to /tmp/bundler20160525-15401-11lp2i/bcrypt-3.1.11/extensions/x86_64-linux/2.2.0/bcrypt-3.1.11/gem_make.out
An error occurred while installing bcrypt (3.1.11), and Bundler cannot
continue.
Make sure that gem install bcrypt -v '3.1.11' succeeds before bundling.
And my gemfile is
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.2'
# 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
gem 'mongoid', '~> 5.1.0'
# 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'
gem "factory_girl_rails"
gem 'ffaker'
gem "shoulda-matchers"
end
group :development do
# 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
group :test do
gem "rspec-rails"
end
gem "devise"
UPDATED
When I Tried uncommenting gem 'bcrypt', '~> 3.1.7' and run bundle install again
I get this error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160525-19540-1s18rpw.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
- 0003-Stop-parsing-on-entities-boundaries-errors.patch
- 0004-Cleanup-conditional-section-error-handling.patch
- 0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch
- 0006-Another-variation-of-overflow-in-Conditional-section.patch
- 0007-Fix-an-error-in-previous-Conditional-section-patch.patch
- 0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch
- 0009-Updated-config.guess.patch
- 0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch
- 0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch
- 0012-Avoid-processing-entities-after-encoding-conversion-.patch
- 0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch
- 0014-CVE-2015-5312-Another-entity-expansion-issue.patch
- 0015-Add-xmlHaltParser-to-stop-the-parser.patch
- 0016-Detect-incoherency-on-GROW.patch
- 0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch
- 0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch
- 0019-Do-not-print-error-context-when-there-is-none.patch
- 0020-xmlStopParser-reset-errNo.patch
- 0021-Reuse-xmlHaltParser-where-it-makes-sense.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0003-Stop-parsing-on-entities-boundaries-errors.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0004-Cleanup-conditional-section-error-handling.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0006-Another-variation-of-overflow-in-Conditional-section.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0007-Fix-an-error-in-previous-Conditional-section-patch.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0009-Updated-config.guess.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0011-Avoid-extra-processing-of-MarkupDecl-when-EOF.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0012-Avoid-processing-entities-after-encoding-conversion-.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0013-CVE-2015-7497-Avoid-an-heap-buffer-overflow-in-xmlDi.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0014-CVE-2015-5312-Another-entity-expansion-issue.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0015-Add-xmlHaltParser-to-stop-the-parser.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0016-Detect-incoherency-on-GROW.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0017-CVE-2015-7500-Fix-memory-access-error-due-to-incorre.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0019-Do-not-print-error-context-when-there-is-none.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0020-xmlStopParser-reset-errNo.patch... OK
Running git apply with /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/patches/libxml2/0021-Reuse-xmlHaltParser-where-it-makes-sense.patch... OK
Running 'configure' for libxml2 2.9.2... OK
Running 'compile' for libxml2 2.9.2... ERROR, review '/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/compile.log' to see what happened. Last lines are:
========================================================================
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include/libxml'
make[3]: Entering directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
make[2]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2/include'
Making all in .
make[2]: Entering directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
CC SAX.lo
CC entities.lo
CC encoding.lo
CC error.lo
CC parserInternals.lo
CC parser.lo
virtual memory exhausted: Cannot allocate memory
make[2]: *** [parser.lo] Error 1
make[2]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2/ext/nokogiri/tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.9.2/libxml2-2.9.2'
make: *** [all] Error 2
========================================================================
*** 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=/usr/local/rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:366:in `block in execute': Failed to complete compile task (RuntimeError)
from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
from /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/mini_portile2-2.0.0/lib/mini_portile2/mini_portile.rb:150:in `cook'
from extconf.rb:289:in `block (2 levels) in process_recipe'
from extconf.rb:182:in `block in chdir_for_build'
from extconf.rb:181:in `chdir'
from extconf.rb:181:in `chdir_for_build'
from extconf.rb:288:in `block in process_recipe'
from extconf.rb:187:in `tap'
from extconf.rb:187:in `process_recipe'
from extconf.rb:478:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /home/vinod/dride/vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/vinod/dride/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.6.7.2/gem_make.out
An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7.2'` succeeds before bundling.

When I increased the Memory & Size of droplet from 521MB to 2GB, this all errors gone and it worked for me.

Related

"An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue"

I am trying to run a bundle install, but when I do, I am getting an error message that says, "An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue." I tried running gem install sqlite3 -v '1.3.13', but am getting an error with that as well.
Here is my Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
group :production do
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'jquery-rails'
gem 'devise'
Here is the error I get when I try to run bundle install:
Kelly#LAPTOP /c/Sites/my_app (master)
$ bundle install
Fetching gem metadata from https://rubygems.org/.............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies..................
Using rake 12.0.0
Using concurrent-ruby 1.0.5 (java)
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6 (java)
Using builder 3.2.3
Using erubi 1.6.0
Using nokogiri 1.8.0 (java)
Using rack 2.0.3
Using nio4r 2.1.0 (java)
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 8.0.0
Using bundler 1.15.1
Using method_source 0.8.2
Using thor 0.19.4
Using puma 3.9.1 (java)
Using sass 3.4.24
Using tilt 2.0.7
Using execjs 2.7.0
Using coffee-script-source 1.12.2
Using turbolinks-source 5.0.3
Using multi_json 1.12.1
Fetching sqlite3 1.3.13
Installing sqlite3 1.3.13 with native extensions
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
Fetching bindex 0.5.0
Installing bindex 0.5.0 with native extensions
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
Using bcrypt 3.1.11 (java)
Using orm_adapter 0.5.0
Using tzinfo 1.2.3
Using loofah 2.0.3
Using rack-test 0.6.3
Using sprockets 3.7.1
Using warden 1.2.7
Using websocket-driver 0.6.5 (java)
Using mime-types 3.1
Using uglifier 3.2.0
Using coffee-script 2.4.1
Using turbolinks 5.0.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13/ext/sqlite3
C:/jruby-9.1.8.0/bin/jruby.exe -r ./siteconf20170707-17112-s04bux.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an
executable file.
You have to install development tools first.
try_do at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:587
block in find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1144
block in checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:941
find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1143
<main> at extconf.rb:50
*** 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=C:/jruby-9.1.8.0/bin/jruby
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13 for inspection.
Results logged to
C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/gem_make.out
An error occurred while installing sqlite3 (1.3.13), and Bundler cannot
continue.
Make sure that `gem install sqlite3 -v '1.3.13'` succeeds before bundling.
In Gemfile:
sqlite3
Here is the error I get when I try to run gem install sqlite -v '1.3.13':
Kelly#LAPTOP /c/Sites/my_app (master)
$ gem install sqlite3 -v '1.3.13'
Building native extensions. This could take a while...
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13/ext/sqlite3
C:/jruby-9.1.8.0/bin/jruby.exe -r ./siteconf20170707-17048-ojikan.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.
try_do at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:587
block in find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1144
block in checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:941
find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1143
<main> at extconf.rb:50
*** 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=C:/jruby-9.1.8.0/bin/jruby
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13 for inspection.
Results logged to C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/gem_make.out
Any help is appreciated as I cannot move forward until I run a successful bundle install and I've tried researching for days and cannot figure out how to fix this.
Updated 7/9/17: Here is my updated Gemfile where I am still not able to run bundle install nor bundle update:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Use sqlite3 as the database for Active Record
gem 'sqlite3', platform: :ruby
gem 'jdbc-sqlite3', platform: :jruby
gem 'activerecord-jdbc-adapter', platform: :jruby
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
group :production do
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'jquery-rails'
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3', '>= 1.3.23'
Updated 7/10/17: After removing gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3', '>= 1.3.23', I tried bundle install again and this time, I got a different error:
Kelly#LAPTOP /c/Sites/my_app (master)
$ bundle install
The dependency sqlite3 (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for x86-mingw32, java but the dependency is only for ruby. To add those platforms to the bundle, run `bundle lock --add-platform ruby`.
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies........................
Using rake 12.0.0
Using concurrent-ruby 1.0.5 (java)
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6 (java)
Using builder 3.2.3
Using erubi 1.6.0
Using nokogiri 1.8.0 (java)
Using rack 2.0.3
Using nio4r 2.1.0 (java)
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 8.0.0
Using bundler 1.15.1
Using method_source 0.8.2
Using thor 0.19.4
Using puma 3.9.1 (java)
Using sass 3.4.24
Using tilt 2.0.7
Using execjs 2.7.0
Using coffee-script-source 1.12.2
Using turbolinks-source 5.0.3
Using multi_json 1.12.1
Using jdbc-sqlite3 3.15.1
Fetching bindex 0.5.0
Installing bindex 0.5.0 with native extensions
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
Using tzinfo 1.2.3
Using loofah 2.0.3
Using rack-test 0.6.3
Using sprockets 3.7.1
Using websocket-driver 0.6.5 (java)
Using mime-types 3.1
Using uglifier 3.2.0
Using coffee-script 2.4.1
Using turbolinks 5.0.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0/ext/bindex
C:/jruby-9.1.8.0/bin/jruby.exe -r ./siteconf20170710-21728-1asiecp.rb extconf.rb
current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0/ext/bindex
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.
current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0/ext/bindex
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.
make failed, exit code 1
Gem files will remain installed in
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0 for inspection.
Results logged to
C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/bindex-0.5.0/gem_make.out
An error occurred while installing bindex (0.5.0), and Bundler cannot continue.
Make sure that `gem install bindex -v '0.5.0'` succeeds before bundling.
In Gemfile:
web-console was resolved to 3.5.1, which depends on
bindex
There has been a perfect answer. Check out the article "An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue Cannot create rails app" in stackoverflow.
I quote the following solution
It's failing because you are missing a dependency. You can get it by running sudo apt-get install libsqlite3-dev
The gem activerecord-jdbcsqlite3-adapter is not yet compatible with Rails 5. I was able to successfully use JRuby with Rails 4.1.3, from a couple of years ago. The team working on JDBC adapters operates on an open source basis, which general means they work for free, so you get what you get.
You have two choices:
1) Uninstall JRuby and use Rails 5 with an MRI-based interpreter; or
2) Use JRuby with an older version of Rails, like 4.2.9 or lower.
My suggestion is to stick with option 1, since you don't have to do anything special at all -- MRI is the normal Ruby interpreter. You also never explained your reasons for choosing JRuby, which makes me suspect a bit of an XY Problem. If you go with option 2, please review your reasons for selecting JRuby and make sure you know both what you're doing and why you're doing it.
This is a very common problem when running a Rails App.
The answer is at this link: https://github.com/sparklemotion/sqlite3-ruby/issues/224
or this Youtube video: https://www.youtube.com/watch?v=G-B_KUFNkQQ&t=556s
Instructions:
Step 1: Open your Gemfile
Step 2: Find where it says:
gem 'sqlite3'
and change this to:
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
(Run "bundle install" if the server still doesn't run.)

rails app wont deploy to heroku

I am trying to push my app to heroku but i keep getting errors. I see that heroku doesnt support sqlite3 and I removed it from the gem file, then bundled. My database.yml file is using postgresql. Maybe something else is trying to use sqlite? How do I fix this issue? Below is the log from heroku after the following command.
$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
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
group :production do
gem 'pg'
gem 'rails_12factor'
end
and shift your sqlite3 gem to
group :development, :test do
gem 'sqlite3'
end
run bundle install --without production and you should be good to go. Remember to push your new code to git before trying to push to Heroku.

I can't do bundle install because of gem pg(0.18.4)

I am using ec2 on aws and trying to deploy my rails app. I successfully git cloned my app to my ec2-user then tried bundle install but which didn't work because of gem pg. I don't know why I can't do bundle install. I tried several solutions on stack overflow but anything didn't work. need your help.
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Rubygems 2.0.14.1 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Using rake 11.1.1
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99.1
Using arel 6.0.3
Using execjs 2.6.0
Using debug_inspector 0.0.2
Using sass 3.4.21
Using byebug 8.2.2
Using net-ssh 3.1.0
Using coffee-script-source 1.10.0
Using thor 0.19.1
Using concurrent-ruby 1.0.1
Using multi_json 1.11.2
Installing pg 0.18.4 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby2.0
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
Gem files will remain installed in /home/ec2-user/.gem/ruby/2.0/gems/pg-0.18.4 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.0/gems/pg-0.18.4/ext/gem_make.out
Using bundler 1.11.2
Using tilt 2.0.2
Using spring 1.6.4
Installing sqlite3 1.3.11 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 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}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby2.0
--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 /home/ec2-user/.gem/ruby/2.0/gems/sqlite3-1.3.11 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.0/gems/sqlite3-1.3.11/ext/sqlite3/gem_make.out
Using rdoc 4.2.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.2
Using rack-test 0.6.3
Using mail 2.6.3
Using autoprefixer-rails 6.3.3.1
Using uglifier 2.7.2
Using binding_of_caller 0.7.2
Using net-scp 1.2.1
Using coffee-script 2.4.1
Using sprockets 3.5.2
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
and my gem file is below
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails_12factor', group: :production
gem 'bootstrap-sass'
gem 'rails', '4.2.5.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'capistrano', '~> 3.4.0'
group :development, :test do
gem 'sqlite3'
end
group :development, :test do
gem 'pg'
end
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
The error is visible in the stack trace:
Can't find the 'libpq-fe.h header
You don't have libpq headers, required for building the PG adapter. Make sure you installed PostgreSQL and the dev dependencies (the libpq-dev package).
Also, you need to cleanup your Gemfile. You have 3 equivalent group :development, :test do declarations.
Plus, you import both the Sqlite3 and PG gems in the same envs. Take a decision about your database, and use only one of them.
Last but not least, you have no database declared for production, hence your deployment to production will fail.
On Linux, just sure install these two
sudo apt-get install postgresql
sudo apt-get install pgadmin3
bundle install
Mixing the answers we have something that worked for me, just run:
sudo apt-get install postgresql libpq-dev
This will install the postgresql (if it's not installed) and will install the missed lib (libpq-dev). That you can see in your error message:
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header

Removed sqlite gem but Heroku still detects sqlite gem and fails

I am trying to deploy a rails app to heroku and I am getting the following error.
Detected sqlite3 gem which is not supported on Heroku
I have removed any reference to sqlite3 from my project and converted it to use 'pg', updated the Gemfile.lock and committed it but the error persists.
Here is my gemfile
source 'https://rubygems.org'
group :test, :development do
#testing
gem 'rspec-rails', '~ 3.0'
gem 'factory_girl_rails', '~ 4.0'
gem 'guard-rspec', require: false
gem 'faker'
gem 'database_cleaner'
end
# Use postgres as the database for Active Record
gem 'pg'
gem 'rails_12factor'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use SCSS for stylesheets
gem 'sass-rails', '~ 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~ 4.0.0'
# See https://github.com/sstephenson/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
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
#gem 'spring', group: :development
# 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
# Use debugger
# gem 'debugger', group: [:development, :test]
ruby '2.0.0'
Here is my database.yml
development:
adapter: postgresql
encoding: SQL_ASCII
database: rock_development
pool: 5
test:
adapter: postgresql
encoding: SQL_ASCII
database: rock_test
pool: 5
Here is my heroku log
ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/.........
Installing i18n 0.6.11
Installing rake 10.3.2
Installing minitest 5.4.2
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Installing rack 1.5.2
Installing json 1.8.1
Installing mime-types 1.25.1
Installing polyglot 0.3.5
Installing arel 5.0.1.20140414130214
Installing coffee-script-source 1.8.0
Installing execjs 2.2.2
Installing thor 0.19.1
Installing hike 1.2.3
Using bundler 1.6.3
Installing multi_json 1.10.1
Installing tilt 1.4.1
Installing sass 3.2.19
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_29a41245e46646e56496208f95c41c97/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_29a41245e46646e56496208f95c41c97/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}/
--enable-local
--disable-local
Gem files will remain installed in /tmp/build_29a41245e46646e56496208f95c41c97/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /tmp/build_29a41245e46646e56496208f95c41c97/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
Installing tzinfo 1.2.2
Installing bcrypt 3.1.7
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.
Bundler Output: Fetching gem metadata from https://rubygems.org/.........
Installing i18n 0.6.11
Installing rake 10.3.2
Installing minitest 5.4.2
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Installing rack 1.5.2
Installing json 1.8.1
Installing mime-types 1.25.1
Installing polyglot 0.3.5
Installing arel 5.0.1.20140414130214
Installing coffee-script-source 1.8.0
Installing execjs 2.2.2
Installing thor 0.19.1
Installing hike 1.2.3
Using bundler 1.6.3
Installing multi_json 1.10.1
Installing tilt 1.4.1
Installing sass 3.2.19
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_29a41245e46646e56496208f95c41c97/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_29a41245e46646e56496208f95c41c97/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}/
--enable-local
--disable-local
Gem files will remain installed in /tmp/build_29a41245e46646e56496208f95c41c97/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /tmp/build_29a41245e46646e56496208f95c41c97/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
Installing tzinfo 1.2.2
Installing bcrypt 3.1.7
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` 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
Problem solved. It was actually a problem with how I was using git. I had created a new branch to make the changes from sqlite to ppsql and I was trying to push to heroku from that branch. Turns out when you say "git push heroku master" it isn't pushing from your current branch, it is pushing from the master branch. Which in my case was still configured to use sqlite.
To solve this problem first merge with your master branch before pushing to heroku.
It may be occur due to when you installed sqlite3 gem it's version details would be stored in Gemfile.lock so remove this file, don't bother of it as it will be again generated without having any source of sqlite3 gem when you run bundle install then after try to deploy on heroku

Rails app using sqlite3 for development won't deploy into heroku

I am trying to deploy a rails app that I created using SQLite3. But after running git push heroku master I keep getting the following error
Initializing repository, done.
Counting objects: 164, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (147/147), done.
Writing objects: 100% (164/164), 78.88 KiB | 0 bytes/s, done.
Total 164 (delta 33), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Installing rake 10.3.2
Installing i18n 0.6.9
Installing minitest 5.3.5
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Installing rack 1.5.2
Installing mime-types 1.25.1
Installing polyglot 0.3.5
Installing json 1.8.1
Installing arel 5.0.1.20140414130214
Installing coffee-script-source 1.7.0
Installing execjs 2.2.0
Installing thor 0.19.1
Using bundler 1.6.3
Installing hike 1.2.3
Installing multi_json 1.10.1
Installing sass 3.2.19
Installing tilt 1.4.1
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/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_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/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}/
--enable-local
--disable-local
Gem files will remain installed in /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
Installing rack-test 0.6.2
Installing tzinfo 1.2.1
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.
Bundler Output: Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Installing rake 10.3.2
Installing i18n 0.6.9
Installing minitest 5.3.5
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Installing rack 1.5.2
Installing mime-types 1.25.1
Installing polyglot 0.3.5
Installing json 1.8.1
Installing arel 5.0.1.20140414130214
Installing coffee-script-source 1.7.0
Installing execjs 2.2.0
Installing thor 0.19.1
Using bundler 1.6.3
Installing hike 1.2.3
Installing multi_json 1.10.1
Installing sass 3.2.19
Installing tilt 1.4.1
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/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_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/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}/
--enable-local
--disable-local
Gem files will remain installed in /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /tmp/build_c9d45d78-4c2b-4825-9bd8-b3961ccc175f/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.9/ext/sqlite3/gem_make.out
Installing rack-test 0.6.2
Installing tzinfo 1.2.1
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` 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
To git#heroku.com:rocky-dusk-1857.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:rocky-dusk-1857.git'
This is my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3', '1.3.8'
gem 'spring'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/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
group :production do
gem 'pg'
gem 'rails_12factor'
end
I deployed all the applications that appeared on the "Rails tutorial" by Michael Hartl with no problem but now I am developing my own apps with slightly newer version of rails and ruby and I am having trouble with this. Any help will be greatly appreciate it.
Data
Heroku doesn't support SQLite3 as it stores data on the hard drive (which will get overwritten on a new push).
A persistent data store (database) is required, and Heroku recommend Postgres.
--
Error
I think your error will have several potential causes:
You've not updated your Gemfile.lock file
You've not committed your Gemfile properly before committing to Heroku
One of your gems depends on sqlite3 (unlikely)
I would resolve the issue like this:
#Gemfile
group :development do
#gem 'sqlite' -> comment out for now
end
group :production do
gem 'pg'
end
Then I would make sure I've committed all the changes:
$ git add .
$ git commit -a -m "Heroku"
$ git push heroku master
This will allow you to push a bona-fide version of your Gemfile to Heroku, consequently allowing you to test the deployment properly
If you need any further assistance, please comment & I'll help!
In order to deploy on Heroku while using the SQL lite gem for development you must:
bundle install --without production

Resources