Rails 在生产中部署 - 总是抱怨 dalli

Rails deployment in production - always complain about dalli

使用我无法在尝试生产部署时摆脱此错误

Could not find cache store adapter for mem_cache_store (cannot load such file -- dalli) (RuntimeError)

我真的不明白。到目前为止,我在开发中部署没有问题,即使我在我的 Gemfile 中将 copy /environments/development.rb 更改为 /environments/production.rb, I still get the same message. I have added the gemdelli`,但它仍然会抱怨。

我不知道这个mem_cache_store是从哪里来的,因为即使我明确地将:memory_store更改为:file_store,错误仍然存​​在

environments/production.rb

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_files = false
  config.assets.js_compressor = :uglifier
  config.assets.css_compressor = :sass
  config.assets.compile = false
  config.assets.digest = true
  config.assets.version = '1.0'
  config.force_ssl = true
  config.log_level = :debug
  ActionMailer::Base.smtp_settings = {
    :address => "localhost",
  }
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.cache_store = :memory_store
  config.log_formatter = ::Logger::Formatter.new
end

Capistrano deploy/production.rb

set :branch, :production
set :stage, :production
set :rails_env, 'production'
set :deploy_to, '/var/www/******'

set :log_level, :debug
set :keep_releases, 5
set :bundle_without, %w{test development}.join(' ') 
set :bundle_flags, '--deployment --quiet'

错误的完整堆栈跟踪

Could not find cache store adapter for mem_cache_store (cannot load such file -- dalli) (RuntimeError)
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache.rb:106:in `rescue in retrieve_store_class'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache.rb:104:in `retrieve_store_class'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache.rb:60:in `lookup_store'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application/bootstrap.rb:76:in `block in <module:Bootstrap>'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
  /usr/local/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
  /usr/local/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  /usr/local/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
  /usr/local/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  /usr/local/lib/ruby/2.0.0/tsort.rb:180:in `each'
  /usr/local/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  /usr/local/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
  /var/www/intranet_rails_test/releases/20150511202754/config/environment.rb:7:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
  /var/www/intranet_rails_test/shared/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `eval'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:28:in `<main>'

使用 Capistrano 3,Rails4.2

有些 gem 需要安装包。 Dalli 使用 memcached。如果你需要 dalli,请使用你的包管理器来安装它(apt-get 等)