1

I am trying to play with redis on my Ubuntu machine and my little script doesn't work. I have installed redis gem and tried this little script (I know its pretty small)

require 'redis'
redis = Redis.new

I get this error :

./redis.rb:4: uninitialized constant Redis (NameError)
from redis.rb:2:in `require'
from redis.rb:2

when I comment the line 2, I dont get any problem. How come the class Redis is not recognized?

1 Answer 1

4

Rename your file to something other than "redis.rb" (try redis_initializer.rb),

require 'redis'

redis = Redis.new
Sign up to request clarification or add additional context in comments.

2 Comments

just one last question : why redis.rb causes a conflict?
I believe it's because when you typed "require 'redis'" ruby actually tried loading your file you created called 'redis.rb'. It didn't look for the gem named 'redis', because it found a file called 'redis' in the script's directory. That's my best guess as to why.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.