部署时出现英雄Sqlite3错误

时间:2016-02-22 05:48:07

标签: ruby-on-rails heroku sqlite

我不断得到一个

remote:        An error occurred while installing sqlite3 (1.3.11), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.11'`  succeeds before bundling.
尝试部署到Heroku时出现

错误,到目前为止我已尝试过所有溢出问题。

这是我的宝石文件

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use sqlite3 as the database for Active Record
gem 'pg'
# 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
gem 'therubyracer'
# 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'
end

group :development do
# 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

这是我的.yml

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

我在想与我的.yml有关但我真的不知道。我可以在本地运行它,但是当我真的

git push heroic master

我收到了这个错误

2 个答案:

答案 0 :(得分:0)

这里的解决方案是: https://devcenter.heroku.com/articles/sqlite3

您需要在生产环境中使用postgresqlsqlite3不受支持 所以要么将适配器更改为postgresql 或者将sqlite3添加到开发和测试组并将postgres添加到生产组

group :development, :test do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end

并将您的database.yml更改为:

# config/database.yml
default: &default
  pool: 5
  timeout: 5000

development:
  <<: *default
  adapter: sqlite3
  database: db/development.sqlite3

test:
  <<: *default
  adapter: sqlite3
  database: db/test.sqlite3

production:
  <<: *default
  adapter: postgresql
  host: localhost
  database: production
  username: postgres
  password: password

答案 1 :(得分:0)

You cannot use SQLite3 on Heroku.用PostgreSQL替换SQLIte3,并更新你的Gemfile。

# replace gem "sqlite3" with
gem "pg"

您只需要更新开发和测试数据库配置。在生产中,database.yml文件由Heroku自动更新。实际上,您甚至不必将其提交到您的存储库。