Search code examples
ruby-on-railsrubydeploymentproductioncapistrano3

Rails deployment in production - always complain about dalli


Using I can't get rid of this error when trying a production deployment

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

I really don't understand. So far I've had no problem deploying in development, and even if I change copy /environments/development.rb into /environments/production.rb, I still get the same message. I have added the gemdelli` in my Gemfile, but it still complains.

I don't know where this mem_cache_store comes from, because even when I explicitely change :memory_store to :file_store, the error remains the same

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'

Full Stack Trace of the error

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>'

Using Capistrano 3, Rails 4.2


Solution

  • Some gems need packages to be installed. Dalli uses memcached. If you need dalli please use your package manager to install it(apt-get, etc)