Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find cache store adapter for redis_store

I have Rails 3.1.3 app and trying to plug gem "redis" to it.

I've added following gem to Gemfile:

gem "redis-store"

Following this article, i've added following code to environments/development.rb:

config.gem "redis-store", :lib => "redis-store"
require "redis-store" # HACK
config.cache_store = :redis_store

The app won't start, complaining to cache_store:

/gems/activesupport-3.1.3/lib/active_support/cache.rb:65:in `lookup_store': Could not find cache store adapter for redis_store (no such file to load -- active_support/cache/redis_store) (RuntimeError).

I've figured it out, including gem "redis-rails" instead of "redis-store", but i'm getting another error:

/Users/AntonAL/.rvm/gems/ree-1.8.7-2011.03@global/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:143:in `gem': redis-store is not part of the bundle. Add it to Gemfile. (Gem::LoadError)

Keeping them both…

gem 'redis-store'
gem 'redis-rails'

…gives another error

…gems/redis-rails-0.0.0/lib/redis-rails/version.rb:1: Redis is not a module (TypeError)
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
    from …/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from …/gems/redis-rails-0.0.0/lib/redis-rails.rb:1
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `require'
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from …/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from …/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from …/config/application.rb:11
    from …/gems/railties-3.1.3/lib/rails/commands.rb:52:in `require'
    from …/gems/railties-3.1.3/lib/rails/commands.rb:52
    from …/gems/railties-3.1.3/lib/rails/commands.rb:49:in `tap'
    from …/gems/railties-3.1.3/lib/rails/commands.rb:49
    from script/rails:6:in `require'
    from script/rails:6

Help, please!

like image 742
AntonAL Avatar asked Mar 19 '12 17:03

AntonAL


4 Answers

try

gem 'redis-store', '~> 1.0.0'
like image 132
pavel.bel Avatar answered Oct 19 '22 07:10

pavel.bel


FYI... I had similar problems until I added all of the following to my Gemfile. I am running Rails 3.2.3.

    gem 'redis'
    gem 'redis-store'
    gem 'redis-rails'
like image 20
Ted B Avatar answered Oct 19 '22 08:10

Ted B


This is all you need:

gem 'redis-rails' # Will install several other redis-* gems

(See: https://github.com/redis-store/redis-rails)

like image 8
Yarin Avatar answered Oct 19 '22 09:10

Yarin


I faced a similar problem with a Rails 5.2 app.

Turns out the problem was with the configuration of the cache store in production.rb. Rails guides indicates using config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'] }, but this is not correct.

What worked for me:

In Gemfile

gem 'redis-rails', '~> 5'

In config/environments/production.rb

config.cache_store = :redis_store, ENV['REDIS_URL']
like image 7
cbrecabarren Avatar answered Oct 19 '22 08:10

cbrecabarren