Cristina Florina
Cristina Florina

Reputation: 1

I'm getting this error: Specified 'sqlite3' for database adapter, but the gem is not loaded

I am trying to run a Ruby on Rails app on Cloud 9 with the following command:

rails s -p $PORT -b $IP 

and I'm getting an error that tells me I don't have sqlite3 in the gem file when I do. This only happened after I pushed my code to Heroku and now it doesn't run in the console any more.

I already tried 'bundle install' and 'bundle update', I also tried to manually install sqlite3 by running 'gem install sqlite3', none of these solved my problem. I also started going through all the steps all over again to see if that issue pops up again, and it does.

source 'https://rubygems.org'

ruby '2.4.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.10'
# 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.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use Haml as the templating library
gem 'haml'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

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

gem 'themoviedb'

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

  gem 'rspec-rails'
  gem 'guard-rspec'

  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :production do
  gem 'pg', '~> 0.21' # for Heroku deployment
  gem 'rails_12factor'
end

Upvotes: 0

Views: 150

Answers (3)

Vinu Joseph
Vinu Joseph

Reputation: 975

Something wrong with sqlite3 versions > 1.4.0 with Rails 5. Mention sqlite3 version explicitly in Gemfile with v1.3.11 or v1.3.13. (gem 'sqlite3', '~> 1.3.11')

Upvotes: 0

halfer
halfer

Reputation: 20420

(Posted on behalf of the question author).

I fixed it eventually, what happened was the version in Gemfile.lock was 'sqlite3 (1.4.0)' but the version I needed was 'sqlite3 (1.3.13)'. I changed the version and ran 'rake db:migrate' and 'rake db:seed' again and now it's working.

Upvotes: 1

infused
infused

Reputation: 24337

Your app is probably running the production environment on Heroku, but your Gemfile only includes sqlite3 in the development & test groups. Move sqlite3 out of the groups so that it is available in all environments and redeploy.

Upvotes: 0

Related Questions