指定' sqlite3'对于数据库适配器,但运行searchkick reindex时没有加载gem?

时间:2018-01-09 08:28:17

标签: ruby-on-rails ruby elasticsearch rake searchkick

首先,我根据环境分离了数据库

group :production do 
  gem 'pg'
end


group :development, :test do
  gem 'byebug'
  gem 'sqlite3'
  gem 'rspec-rails'
end

添加几条记录后。我在生产中运行了以下reindex命令。

bundle exec rake searchkick:reindex CLASS=Book

但它会出现以下错误

rake aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its v                                                   ersion is at the minimum required by ActiveRecord).
/book/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.                                                   rb:176:in `rescue in spec'
/book/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.                                                   rb:173:in `spec'
/book/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/connection_handling.rb:53:in `establish_conne                                                   ction'
/book/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/railtie.rb:125:in `block (2 levels) in <class                                                   :Railtie>'

Caused by:
Gem::LoadError: sqlite3 is not part of the bundle. Add it to your Gemfile.
/home/deploy/.rvm/gems/ruby-2.4.2/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:404:in `block (2 levels) in replace_gem'
/book/shared/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:7:in `                                                   <top (required)>'

我感谢任何帮助,为什么它正在搜索sql虽然pg是为生产设置的?

更新

好的,我通过在rails控制台制作中执行Book.reindex解决了这个问题,但我仍然想知道原因

bundle exec rake searchkick:reindex CLASS=Book

因上述错误而失败?它一开始就在工作。在进行一些升级之后,例如添加aws-sdk,它开始显示错误。 aws-sdk会破坏它吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试在制作组

上添加gem 'rails_12factor'

的Gemfile

 group :production do 
    gem 'pg'
    gem 'rails_12factor'
 end

然后

bundle install
bundle update 

然后推进生产并进行测试

希望能提供帮助