Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis::CommandError: ERR invalid DB index when running rspec

I just started working on an existing Rails codebase and I'm trying to run the tests in the codebase. However, when I run bundle exec rspec spec/ I get the following error on every test:

Failure/Error: Unable to find matching line from backtrace
Redis::CommandError:
   ERR invalid DB index
 # ./lib/redised.rb:35:in `flushdb_all'
 # ./lib/redised.rb:35:in `each_value'
 # ./lib/redised.rb:35:in `flushdb_all'

I'm pretty new to rails -- I've only finished 8 of the 11 chapters in Michael Hartl's rails tutorial -- so I'm not familiar with Redis. My Redis version is redis-2.4.17.

like image 544
MaxGabriel Avatar asked Jan 11 '13 21:01

MaxGabriel


2 Answers

The problem was that I needed to increase the number of databases. To do so, I went to /usr/local/etc and modified redis.conf. I set the database number to 128: databases 128.

like image 127
MaxGabriel Avatar answered Sep 18 '22 15:09

MaxGabriel


Though it is too late but may be helpful for others.

If you are using database name like 'test' please replace it something index like '0' / 0. If you are not sure of index try 0 as your index.best of luck

like image 45
Suben Saha Avatar answered Sep 19 '22 15:09

Suben Saha