Installing Sqlite3 for Ruby (Mac OSX 10.5.8)

Morgan Allen picture Morgan Allen · Oct 9, 2011 · Viewed 8.5k times · Source

I am following this guide ATM - http://guides.rubyonrails.org/getting_started.html#getting-up-and-running-quickly-with-scaffolding

When trying to create a database, I got:

Morgans-Computer:blog Morgan$ rake db:create Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in your Gemfile. Run bundle install to install missing gems.

When I try to run 'bundle install', I get more errors:

Installing sqlite3 (1.3.4) with native extensions /Users/Morgan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:551:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

    /Users/Morgan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 

I have tried to install the Ruby Gem Sqlite3 (http://rubygems.org/gems/sqlite3-ruby) but it continues to fail. I found another post on here saying that I need to install C because that is what the compiler is written in? Wasn't sure exactly what that meant, or how I go about doing it.

Any help would be greatly appreciated!!

Answer

Blake Taylor picture Blake Taylor · Oct 9, 2011

If you don't already have homebrew installed, I would set that up first. It's a nice package manager and allows you to install things like sqlite with brew install sqlite.

To install brew you'll need xcode installed. If you don't already have that you'll probably need the cd that came with you system, or you can download from apple's website. On the latest OS, you can install it from the App Store which is nice (This might work for you too).

If you have mysql and would prefer to use that instead and sidestep the sqlite issue you can generate your rails project as such.

rails new my_new_project -d mysql