Rails Server Gem Load Error – SQlite3

rubyruby-on-rails

Let me start out with, I have searched and read all questions asked similar to my issue and have tried all suggestions. Here's some of the technology I'm using, if it helps:

  • Initially, High Sierra on an early 2015 macbook(now upgraded to Mojave)
  • ruby 2.5.1
  • rails -5.0.0
  • sublime3
  • iterm2
  • chrome + safari

Following Pragmatic studios Rails 1 course I installed ruby 2.5.1 and rails 5.0.0 new
bundle check and all dependencies are satisfied
bundle install etc…

So now I have a new rails app setup and I try rails s the Puma server runs the app seemingly without issue but when I try and load the browser localhost3000 I get an error:

Gem::LoadError
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).

When I refresh the page while running the server I get this error:

ActiveRecord::ConnectionNotEstablished
No connection pool with id primary found.

I have checked gem file and sqlite3 is there. I have re-installed sqlite3. I have done bundle exec rails server. I have uninstalled sqlite3 and reinstalled. I have deleted the Gemfile.lock file and did bundle install(and exec). I have tried every suggestion I could find online.

So now I thought, well maybe my system is messed up and I could use an upgrade to Mojave.

So…
I created a bootable drive deleted the HD and did a clean install.

Now running Mojave with the same apps listed above reinstalled.

So I run rails s – same sequence of errors!? Here's what I have in Gemfile and Gemfile.lock:

Gem file:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
#gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
----------

Gem Lock:

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.0.7.1)
      actionpack (= 5.0.7.1)
      nio4r (>= 1.2, < 3.0)
      websocket-driver (~> 0.6.1)
    actionmailer (5.0.7.1)
      actionpack (= 5.0.7.1)
      actionview (= 5.0.7.1)
      activejob (= 5.0.7.1)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.0.7.1)
      actionview (= 5.0.7.1)
      activesupport (= 5.0.7.1)
      rack (~> 2.0)
      rack-test (~> 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.0.7.1)
      activesupport (= 5.0.7.1)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.0.7.1)
      activesupport (= 5.0.7.1)
      globalid (>= 0.3.6)
    activemodel (5.0.7.1)
      activesupport (= 5.0.7.1)
    activerecord (5.0.7.1)
      activemodel (= 5.0.7.1)
      activesupport (= 5.0.7.1)
      arel (~> 7.0)
    activesupport (5.0.7.1)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    arel (7.1.4)
    bindex (0.5.0)
    builder (3.2.3)
    byebug (11.0.0)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.1.4)
    crass (1.0.4)
    erubis (2.7.0)
    execjs (2.7.0)
    ffi (1.10.0)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    i18n (1.5.3)
      concurrent-ruby (~> 1.0)
    jbuilder (2.8.0)
      activesupport (>= 4.2.0)
      multi_json (>= 1.2)
    jquery-rails (4.3.3)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    listen (3.0.8)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    loofah (2.2.3)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    method_source (0.9.2)
    mini_mime (1.0.1)
    mini_portile2 (2.4.0)
    minitest (5.11.3)
    multi_json (1.13.1)
    nio4r (2.3.1)
    nokogiri (1.10.1)
      mini_portile2 (~> 2.4.0)
    puma (3.12.0)
    rack (2.0.6)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (5.0.7.1)
      actioncable (= 5.0.7.1)
      actionmailer (= 5.0.7.1)
      actionpack (= 5.0.7.1)
      actionview (= 5.0.7.1)
      activejob (= 5.0.7.1)
      activemodel (= 5.0.7.1)
      activerecord (= 5.0.7.1)
      activesupport (= 5.0.7.1)
      bundler (>= 1.3.0)
      railties (= 5.0.7.1)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.4)
      loofah (~> 2.2, >= 2.2.2)
    railties (5.0.7.1)
      actionpack (= 5.0.7.1)
      activesupport (= 5.0.7.1)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.3.2)
    rb-fsevent (0.10.3)
    rb-inotify (0.10.0)
      ffi (~> 1.0)
    sass (3.7.3)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (3.7.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.4.0)
    thor (0.20.3)
    thread_safe (0.3.6)
    tilt (2.0.9)
    turbolinks (5.2.0)
      turbolinks-source (~> 5.2)
    turbolinks-source (5.2.0)
    tzinfo (1.2.5)
      thread_safe (~> 0.1)
    uglifier (4.1.20)
      execjs (>= 0.3.0, < 3)
    web-console (3.7.0)
      actionview (>= 5.0)
      activemodel (>= 5.0)
      bindex (>= 0.4.0)
      railties (>= 5.0)
    websocket-driver (0.6.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)

PLATFORMS
  ruby

DEPENDENCIES
  byebug
  coffee-rails (~> 4.2)
  jbuilder (~> 2.5)
  jquery-rails
  listen (~> 3.0.5)
  puma (~> 3.0)
  rails (~> 5.0.0)
  sass-rails (~> 5.0)
  spring
  spring-watcher-listen (~> 2.0.0)
  sqlite3
  turbolinks (~> 5)
  tzinfo-data
  uglifier (>= 1.3.0)
  web-console

BUNDLED WITH
   1.16.6
---------

Best Answer

Mike Clark from PragmaticStudio Solved this for me!

Ah, looks like it’s an issue with the sqlite3 v1.4.0 gem which was released on February 4. There’s a fix in the works:

https://github.com/rails/rails/issues/35153

In the meantime, you can fall back to v1.3.6 by adding that version to the “sqlite3” line in your Gemfile, like so:

gem "sqlite3", "~> 1.3.6”

Then make sure to “bundle install”.

Anyway, that solved the issue for me. I also found this helpful:

https://stackoverflow.com/questions/54527277/cant-activate-sqlite3-1-3-6-already-activated-sqlite3-1-4-0/54606137#54606137

Give that a try and see if it works for you.

Related Question