Reputation: 15
I am trying to push my app to heroku. I am getting errors in the terminal saying: An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue. Also, ake sure that gem install sqlite3 -v '1.3.11'
succeeds before bundling. I've been reading a lot about sqlite2 and pg, but cant seem to figure out how to integrate this into my gemfile. Thank you.
Here is my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
# 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 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
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# 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
Thanks
Upvotes: 0
Views: 91
Reputation: 100
Tim is right, Heroku does not support SQLite, and prefers the usage of PostgreSQL. However, if you have already started your rails application and are ready to push to heroku, you no doubt have already begun to use SQLite, hence the error you get when trying to push. Currently your Gemfile has neither PostgreSQL(pg) or SQLite(sqlite3) in it, which is probably causing it's own set of problems.
To get around this, you can use production and test grouping within your Gemfile
i.e.
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
gem 'byebug'
gem 'other-gems'
end
If you don't have a staging environment set with Heroku, upon deployment, PostgreSQL (pg) will become the default database setting. Allowing you to keep working locally with whatever you have already done and with PostgreSQL in production.
Upvotes: 0
Reputation: 698
To use sqlite3 on your project just the line below on your gemfile:
gem 'sqlite3'
To use postgres as database add:
gem 'pg'
Remember to install the postgres packages on your system, if you're using ubuntu it should be:
sudo apt-get install postgres libpq-dev
Upvotes: 2
Reputation: 129
SQLite is a great way to start a project and works well when working with small data sets on a local machine. Heroku on the other hand requires a little more than SQLite has to offer. When using Heroku with Rails they prefer you to use PostgreSQL. Check out their docs on SQLite and PostgreSQL
https://devcenter.heroku.com/articles/sqlite3
Switching to a PG database takes a little more work than if you had originally made the app with it, but it's not impossible. That link above has steps to help you switch SQLite to PostgreSQL.
Heroku has awesome docs for their Rails integration. if you need some more info check out https://devcenter.heroku.com/categories/ruby
Upvotes: 4