Search code examples
ruby-on-railssqlitegemfile

How can I run rails with Sqlite3 on Mac? I'm getting " gem is not loaded" but it was included on Gemfile


I would like to create a new rails app using Sqlite but I have found some issues. I am using Rails 5.0.7.1 properly installed and gem 'sqlite3' included in my Gemfile. The version of sqlite3 in my system (Mac OS) is 3.24.0 2018-06-04 14:10:15 95fbac39baaab1c3a84fdfc82ccb7f42398b2e92f18a2a57bce1d4a713cbaapl

Running the rails server and accessing to my localhost:3000 give me the error:

Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

The gem was installed running bundle install and I can see it in my Gemfile.lock sqlite3 (1.4.0)

I don't know what is the issue. Anyone could help me? Thanks!


Solution

  • I had issues with sqlite3(1.4.0) with the older version of ruby/rails(2.5/5.2). You can try specifying the lower version of sqlite3 in Gemfile and running the bundle again.

     gem 'sqlite3', '~> 1.3.13'
    

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