Error with sqlite3 when running bundle install
Asked Answered
J

6

6

So I was trying to run bundle install in my newly created Rails app when I got this error:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150114-6877-1x6zk4k.rb 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

extconf failed, exit code 1

Gem files will remain installed in /var/folders/mc/qsk02mn50x96msk9zjxgzbmh0000gn/T/bundler20150114-6877-jsv17e/sqlite3-1.3.10/gems/sqlite3-1.3.10 for inspection.
Results logged to /var/folders/mc/qsk02mn50x96msk9zjxgzbmh0000gn/T/bundler20150114-6877-jsv17e/sqlite3-1.3.10/extensions/universal-darwin-14/2.0.0/sqlite3-1.3.10/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.

My current sqlite3 version:

3.8.7.4 2014-12-09 01:34:36 f66f7a17b78ba617acde90fc810107f34f1a1f2e

Ruby:

ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Brew:

0.9.5

Further info:

$ which sqlite3
/usr/local/bin/sqlite3
$ whereis sqlite3
/usr/bin/sqlite3

Does this have anything to do with the clashing of Ruby 2.0 and the default Ruby 1.8 that came with my OS X? I'm using OS X 10.10.

How can I solve this problem? Thank you very much!

Juggler answered 14/1, 2015 at 14:21 Comment(0)
J
3

So I found the solution: Simply (manually) uninstall any existing versions of sqlite3 in your computer. What I did was:

  1. Run which -a sqlite3 to find out the directories in which sqlite3 was installed (for me there were 4 versions O.o). Delete all those sqlite3 files (by rm)
  2. Manually delete all the sqlite-related files in /usr/local/lib, usr/local/bin and usr/local/include
  3. After all the deletion, run bundle install again in your app dir, and the required version of sqlite3 will automatically be installed.

    $bundle install Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... // Using a bunch of gems Installing sqlite3 1.3.10 Installing turbolinks 2.5.3 Installing uglifier 2.7.0 Installing web-console 2.0.0 Your bundle is complete! Use 'bundle show [gemname]' to see where a bundled gem is installed.

I hope this saves some of your time, if you encountered the same problem as I did. Thanks!

Juggler answered 14/1, 2015 at 16:41 Comment(0)
S
11

check where your sqlite is installed to and run the following command (i assume /opt/local here)

gem install sqlite3 -- --with-sqlite3-dir=/opt/local

then

bundle install
Soerabaja answered 14/1, 2015 at 14:34 Comment(3)
hi! I came across the same answer on another post, tried it out but it didn't work. For my case, I used gem install sqlite3 -- --with-sqlite3-dir=/usr/local/ The same error message was displayedJuggler
sorry to hear that. it worked for me. you sure you checked that your sqlite3 installation is inside /usr/local? also is the command 'gem install sqlite3 --' working?Soerabaja
I somehow got 4 different versions of sqlite3 installed on my computer. I think that was the source of confusion. So I uninstalled them all and let bundle install handle the sqlite3 installation and it worked fine. Thanks for your reply man!Juggler
J
3

So I found the solution: Simply (manually) uninstall any existing versions of sqlite3 in your computer. What I did was:

  1. Run which -a sqlite3 to find out the directories in which sqlite3 was installed (for me there were 4 versions O.o). Delete all those sqlite3 files (by rm)
  2. Manually delete all the sqlite-related files in /usr/local/lib, usr/local/bin and usr/local/include
  3. After all the deletion, run bundle install again in your app dir, and the required version of sqlite3 will automatically be installed.

    $bundle install Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... // Using a bunch of gems Installing sqlite3 1.3.10 Installing turbolinks 2.5.3 Installing uglifier 2.7.0 Installing web-console 2.0.0 Your bundle is complete! Use 'bundle show [gemname]' to see where a bundled gem is installed.

I hope this saves some of your time, if you encountered the same problem as I did. Thanks!

Juggler answered 14/1, 2015 at 16:41 Comment(0)
V
1

Try installing those in your console :

Install brew :

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)""

# Add Homebrews binary path to the front of the $PATH
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile

brew install sqlite3
brew install libsqlite3-dev
bundle install

Please check this link !

Virgenvirgie answered 14/1, 2015 at 14:28 Comment(5)
oops did not notice, you are asking of OS X !Virgenvirgie
Updated answer, please check.Virgenvirgie
It's not my question ;) I hope joeleba will see your answer.Biodegradable
Thanks for the reply! brew install libsqlite3-dev: Error: No available formula for libsqlite3-dev Searching formulae... Searching taps... and bundle install still returns the same error :-<Juggler
brew list -1 | while read line; do brew unlink $line; brew link $line; done Run this command befor the brew install sqlite3Virgenvirgie
A
0

I'm just adding my own solution for people other to try in case the above did not work for them.

I had to brew uninstall sqlite3 then I had to remove the sqlite3s from the rails app directory.

using sudo rm -fr {app_route}/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/

then used bundle install to reinstall sqlite3.

Able answered 6/7, 2018 at 9:57 Comment(0)
L
0

This worked for me within a Dockerfile context on debian flavour:

apt-get install -y sqlite3 libsqlite3-dev
gem install sqlite3    # or: `bundle install`

.. and it worked!

Lette answered 12/1, 2021 at 11:23 Comment(0)
T
-1

When you try to create a new project, then the rails try to create by latest version of the rails. Therefor, bundle install raised some errors.

When you create a new project, you can specify the version of the rails, which you have installed to OS X like following.

$ rails -v
Rails 4.x.x

After that, you can create new project like following.

$ rails _4.x.x_ new PROJECT_NAME
Twentyfour answered 15/10, 2015 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.