1

When running the gem install sqlite3 command on Mac OS X I experience the following error message:

    Users-MacBook-Pro:~ user$ gem install sqlite3
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    /Users/user/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
checking for sqlite3.h... *** 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=/Users/user/.rvm/rubies/ruby-2.1.2/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
/Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header'
    from extconf.rb:35:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/user/.rvm/gems/ruby-2.1.2/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9/gem_make.out
Users-MacBook-Pro:~ user$ 

I am relatively new to using the terminal, ruby on rails and ruby gems and have been scratching my head (i.e. searching google) for a few hours now, any help would be greatly appreciated. Have tried the sudo command but no luck there.

  • Can you tell us the output of gem -v, ruby -v, rails -v, rvm version and rvm list? – CleoR Sep 15 '14 at 00:19
  • I have gem version 2.2.2, ruby 2.1.2 and rails 4.1.6. I also have sqlite3 3.7.7 which is a requirement for the sqlite3 gem see [link] (https://rubygems.org/gems/sqlite3). – Mark Williams Sep 15 '14 at 12:00
  • possible duplicate of [sqlite3 gem fails to install](http://stackoverflow.com/questions/5025680/sqlite3-gem-fails-to-install) – Brad Werth Sep 15 '14 at 17:02
  • @BradWerth Thanks for the link, unfortunately the answers have not resolved the issue, still getting the same error. May try reinstalling sqlite3 to see if I get any joy? - will let all know the outcome. – Mark Williams Sep 15 '14 at 22:57
  • The key is "You have to install development tools first." – Brad Werth Sep 15 '14 at 23:04
  • @BradWerth I've been trying to follow a beginners tutorial on the Ruby on Rails website [link] (http://guides.rubyonrails.org/getting_started.html#creating-a-new-rails-project) but there is no mention of development tools being a pre-requisite. Do you know where I can find instruction on how to install these "development tools"? - Thanks for your help. – Mark Williams Sep 16 '14 at 00:27
  • http://stackoverflow.com/questions/8676050/struggling-with-sqlite3-gem-on-os-x-lion?rq=1 – Brad Werth Sep 16 '14 at 02:18
  • If that worked you should put it in a comment to get checked – CleoR Sep 18 '14 at 04:37
  • No joy yet, have checked that I have all of the required dependencies setup, have brew installed sqlite and have even updated my operating system to OS X maverick 10.9.5 same error message is experienced when running 'gem install sqlite3' command. – Mark Williams Sep 20 '14 at 16:48

2 Answers2

1

You should install sqlite3 in your OSX first

brew install sqlite3
The Lazy Log
  • 3,404
  • 2
  • 18
  • 26
1

Ok, so I ended up throwing the kitchen sink at this one in the end. Here are the steps I took to resolve the issue.

  1. uninstalled RVM link
  2. uninstalled App Store version of xcode as had it previously installed link
  3. ran $ xcode-select --install in terminal to install command line tools
  4. as I already have Homebrew installed I added Homebrews binary path to the front of the $PATH link

    $ echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
    $ source ~/.bash_profile
    
  5. ran $ brew install sqlite3 command
  6. reinstalled RVM

I believe the steps which mitigated the issue the most were 2,3,4 and 5.

Hope this helps!

Community
  • 1
  • 1