Search code examples
ruby-on-railsrubysqliteruby-on-rails-4ruby-2.0

Ruby on Rails - "Add 'gem sqlite3'' to your Gemfile"


I was following the Rails tutorial, but I got stuck when it said to type rails server in the blog directory. It states

Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile.

I quit the server, installed sqlite3, reinstated the server, only to get this message again. sqlite3 doesn't show up when I do gem list, but I do see the folder in my Root Ruby directory.

How can I fix this error?

I'm using Ruby 2.0, Rails 4.0, sqlite3 1.3.7.


Solution

  • Problem Solved!

    Turns out, it was several different problems:

    1. I previously overlooked that sqlite3 needed to be installed in order to run, as stated in rubyonrails.org's Getting Started guide. The guide gave me a link to sqlite.com, from which I needed to download the command shell and the dll, both are under "Precompiled Binaries for Windows". More on this below.

    2. The gem install gave me an error that stated it couldn't download anything from rubygems.org. Turns out, there was a new version of rubygems I wasn't aware of. Fixed with gem update --system.

    3. I tried gem install sqlite3 --platform=ruby, but to no avail. It couldn't build a native extension and couldn't find sqlite3.h.

    4. I had asked my question also on ruby-forums. http://www.ruby-forum.com/topic/4415126 Here, a Joel Pearson(virtuoso) provided the missing files that I needed via attachment, since these files are not provided in sqlite.com. I followed his instructions, including putting the shell and dll files in my root Ruby's bin directory...and it worked!

    So basically, I was able to install sqlite3 without modifying any Gemfile or Gemfile.lock. My gem list shows sqlite3 (1.3.7) and Rails's Welcome screen now appears as the Getting Started guide shows! I use Windows 7-64 bit, Ruby 2.0, Rails 4.0 and I now got sqlite3 1.3.7.

    Thank you very much everyone for giving this n00b advice and direction. I find that having explored the Gemfiles as well as my root Ruby directory, I understand how Ruby and Rails are fit into my computer better.

    As a beginner, I would recommend being able to download the sqlite3 files and folders needed to install it on Windows both on rubyonrails.org's Getting Started guide and in sqlite.com.

    Thanks again! hewhocomes