问题
The environment:
Ubuntu 9.10 (run within VirtualBox)
Ruby v1.8.7
Redis gem v2.0.6
On irb, when I try to initialize Redis I get a RuntimeError
. Here's a snippet:
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'redis'
WARNING: using the built-in Timeout class which is known to have issues when used for opening connections. Install the SystemTimer gem if you want to make sure the Redis client will not hang.
=> true
irb(main):003:0> r = Redis.new
RuntimeError: -ERR unknown command
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:172:in `format_error_reply'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:162:in `format_reply'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:105:in `read'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:35:in `call'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:63:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:245:in `ensure_connected'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:61:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:199:in `logging'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:60:in `process'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis/client.rb:34:in `call'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis.rb:51:in `info'
from /usr/lib/ruby/gems/1.8/gems/redis-2.0.6/lib/redis.rb:560:in `inspect'
from /usr/lib/ruby/1.8/irb.rb:302:in `output_value'
from /usr/lib/ruby/1.8/irb.rb:151:in `eval_input'
from /usr/lib/ruby/1.8/irb.rb:263:in `signal_status'
from /usr/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /usr/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/lib/ruby/1.8/irb.rb:69:in `catch'
from /usr/lib/ruby/1.8/irb.rb:69:in `start'
from /usr/bin/irb:13irb(main):004:0> exit
Has anybody run into this before? Any ideas?
回答1:
If your redis is the one provided by the 9.10 distribution, the version is too old to be ran with the 2.x gem. The 2.x gem expect at least a 1.2 redis
来源:https://stackoverflow.com/questions/3696932/runtimeerror-err-unknown-command-running-redis-gem-on-ruby