While working my way through Agile Web Development with Rails (yes I’m learning Rails and Ruby, more on this too later) I ran into the following error:

SQLite3::SQLException: near “ADD”: syntax error: ALTER TABLE products ADD “date_available” datetime

while trying to add a column through a migration. Searching Google took me to a couple of places, but it took a while to find a result that explained how to resolve this issue.

Luckily I came across this post by Mark Cornick, which explained that the issues was caused by the version of SQLite3 that is included in OS X 10.4.

After downloading and installing (from source) the latest version of SQLite3, and uninstalling and reinstalling the sqlite3-ruby gem

sudo gem uninstall sqlite3-ruby
sudo gem install sqlite3-ruby

I was able to run the migration to add the column and continue on.

6 Responses to “Rails, SQLite3 and OS X”

  1. Eddie Says:

    Thanks! This was driving me crazy.

  2. hide Says:

    Hi Eddie,

    No problem. I’m glad my experience has been useful.

  3. nicolas Says:

    …and an other guy who says thank you ’cause he was “driven crazy”

  4. Marco Forlin Says:

    Thanks!!! I spend 2 hours, and i find the solution thanks to you!

  5. Mark Dodwell Says:

    I accidentally installed a version of sqlite over the top of my system’s one. I’m on OS X 10.4 and it has pretty much broken most of the applications (I think they all use CoreData which uses some of the sqlite libs). Does anybody have any ideas for how I can restore the original version without a complete reinstall of the OS?

    I believe that the OS X 10.4 version comes with a patched version of sqlite 3.1.3. Perhaps I could obtain that from somewhere? I have hunted high and low on the Internet with no luck.

    Any ideas welcome!!

  6. Pedro Says:

    I installed the last sqlite3 version via macports but continued getting that error. Until I read your sentence: “reinstalling the sqlite3-ruby gem”.

    Thanks!

Leave a Reply