Ruby On Rails SQLite errors when creating new project - ruby-on-rails

I've been working with ruby recently, I really like the language and have been picking it up really quick I decided it was time to try and work with the Rails framework. When I try to create a new project my typing
rails new first-site
I get the following errors I've spent hours Googling it and haven't found any similar result
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' 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=/usr/local/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 /usr/local/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.8 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.8/ext/sqlite3 /gem_make.out
An error occurred while installing sqlite3 (1.3.8), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.8'` succeeds before bundling.
I then run the gem install sqlite3 -v '1.3.8' and get similar errors.
I have no idea what I'm doing wrong.

Looks like you need to install sqlite
That is where the
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel'
If you have another db setup like postgres you can run it with the database switch
rails new myapp --database=postgresql

I found out I was missing developer dependencies when trying to use the MySQL gem. All is fixed now :)

Related

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

I keep getting the below error in rails on windows when I try to make a new rails app? It fails when it gets to installing sqlite3.
current directory:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.0/ext/sqlite3
C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190220-14164-174xy0j.rb extconf.rb
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... no
checking for dlopen()... no
missing function dlopen
*** 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:/Ruby25-x64/bin/$(RUBY_BASE_NAME)
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
--with-pthreadlib
--without-pthreadlib
--with-dllib
--without-dllib
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.0 for inspection.
Results logged to
C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.0/gem_make.out
An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.4.0' --source 'https://rubygems.org/'`
succeeds before bundling.
I have sqlite3 installed on my machine and I am using windows 10. I have attempted ot run the gem install sqlite3 command like it prompts me to but it still fails what am I doing wrong?
Try this
$ sudo apt-get install libsqlite3-dev
then,
$ bundle install
Probably, you use different rails version.
Solution is change version of sqlite to 1.3.6:
gem 'sqlite3', '~> 1.3.6'
After this change run command:
bundle update
Hi I got the same message when tried to install SQLite gem without MinGW gem installed already
C:\Sites>ridk exec pacman -S mingw-w64-x86_64-dlfcn
Install it and try again
If you DON'T have installed RailsInstaller only Ruby DevKit it should work. If not please try uninstalling it first, removing the remaining folders and installing rails by command gem install rails
Try uninstalling all the versions of the sqlite3 gem from the system and reinstalling only version 1.4.0

Rails pdf-extract gem has sqlite as dependency, but I'm using pg because Heroku requires it so bundle install fails

I've been trying to install pdf-extract as a gem in my Rails app. When I go to build, I get this error because it uses sqlite as a dependency:
Fetching sqlite3 1.3.13
Installing sqlite3 1.3.13 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
/home/vagrant/.rbenv/versions/2.3.0/bin/ruby -r ./siteconf20180425-3298-14ft47q.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'brew install sqlite3',
'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=/home/vagrant/.rbenv/versions/2.3.0/bin/$(RUBY_BASE_NAME)
--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:
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/sqlite3-1.3.13/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.13 for inspection.
Results logged to /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/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:
pdf-extract was resolved to 0.1.1, which depends on
sqlite3
Is there anyway I can still use pdf-extract? Heroku doesn't allow sqlite in production.
Any help is greatly appreciated.
EDIT:
For those who encounter this issue in the future: I attempted to hack the gem to get it to work with postgres--this seemed to work though it caused the gem's performance to tank. Ultimately, I created an entirely separate api-only app, deployed directly to AWS using Elastic Beanstalk rather than through Heroku so that app could use sqlite3, and called the api-app to implement the gem functionality in my original app.
This approach would likely work well for any gems that cause dependency issues in a preexisting Rails app.
There is no way to use a gem that has a dependency if you cannot install that dependency. Your options are to
Use a different PDF Gem
Use an alternative to Heroku
Find a way to implement the functionality you need from Pdf-extract yourself without using any gems
Go through the gem's code to see where it uses sqlite and try to get rid of that code without breaking the gem
I would save yourself the time and trouble involved with getting this to work and look at alternative libraries. There is a PDF text extraction gem called HyPDF that is also a Heroku add-on.

Error installing sqlite3, Failed to build gem native extension

I've referred to the following solution on stackoverflow, yet I'm still experiencing the same issue:
(Error installing mysql2: Failed to build gem native extension),
The below command referenced in the link above did not remediate the issue:
brew install mysql
Evidently, the issue persists, returning the following output:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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}/
--with-sqlite3lib
--without-sqlite3lib
Gem files will remain installed in /var/folders/fb/tvgwnxc10lq6kd5xxwcg_0nw0000gn/T/bundler20150210-28601-nw7oyi/sqlite3-1.3.10/gems/sqlite3-1.3.10 for inspection.
Results logged to /var/folders/fb/tvgwnxc10lq6kd5xxwcg_0nw0000gn/T/bundler20150210-28601-nw7oyi/sqlite3-1.3.10/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.
➜ code
I would sincerely appreciate assistance. Thank you!
The following commands remediated my issue:
brew unlink sqlite
brew install sqlite3 --universal
sudo gem install sqlite3 -- --with-sqlite3-dir=/usr/local/Cellar/sqlite/3.8.8.1
My long-time friend working in InfoSec assisted me. According to him, my SQLite3 updates were directing to the wrong bin. I hope this helps anyone experiencing the same frustrating issue. Thank you!

Error on "rails new" command (using rbenv)

I have rbenv installed, ruby, and rails installed, but the command to create the new rails project is causing an exception around sqlite.
rails new first_app
.
.
.
Using sass (3.2.3)
Using sass-rails (3.2.5)
Installing sqlite3 (1.3.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/alundgren/.rbenv/versions/1.9.3-p327/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' 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=/home/alundgren/.rbenv/versions/1.9.3-p327/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}/lib
--enable-local
--disable-local
Gem files will remain installed in /home/alundgren/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6 for inspection.
Results logged to /home/alundgren/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
I've tried installing the sqlite gem and rehashing rbenv, but same error. Does anyone have any ideas on how to fix this, what the exact gem name is, etc?
I had the same issue and I installed a the sqlite package on ubuntu:
apt-get install libsqlite3-dev
The problem is that you are missing the required header files to compile the mysql adapter. The error suggests "Try 'port install sqlite3 +universal' or 'yum install sqlite-devel' and check your shared library search path (the location where your sqlite3 shared library is located)". I would do that first, as this will ensure that you have the correct header files on your machine. Once you have them, you may have to specify the location of the files to the compiler, the "--with-sqlite3-include" directive will probably do the trick.
You do not seem to have sqlite installed on your box. The gem will not installed without the underlying being present.
Please do:
macosx: brew install sqlite
enterprise linux: sudo yum install libsqlite3-dev
ubuntu: sudo apt-get install libsqlite3-dev

issues with rails on EC2 when calling 'build install'

Just finished spinning an instance of EC2 on amazon and installed rails and ruby. When I tried to call bundle install however, I am getting the following error:
Installing sqlite3 (1.3.3) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to bui ld gem native extension. (Gem::Installer::ExtensionBuildError)
/usr/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite3-devel' 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=/usr/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}/lib
yes I have run 'yum install sqlite3-devel'.
Maybe also try:
yum install sqlite3
yum install ruby-devel
I had the same issue. Thanks to this forum entry, I figured it out: http://railsforum.com/viewtopic.php?id=22116
You've got to:
sudo yum install make
sudo yum install gcc
Surprisingly, they are not standard in AWS AMI. I was on a wild goose chase, trying to solve the problem by making sqlite3.h available, but it was a more basic problem all along. Both make and gcc were missing. Hope that also helps your case.

Resources