Wednesday, May 26, 2010

Ruby memcached client on Ubuntu

It was a pain to figure out how to install a Ruby memcached library. Here's the error in 'irb' for requiring the basic library:

irb(main):001:0> require 'memcached'
LoadError: no such file to load -- rlibmemcached
from /var/lib/gems/1.9.1/gems/memcached-0.19.5/lib/memcached.rb:19:in `require'
from /var/lib/gems/1.9.1/gems/memcached-0.19.5/lib/memcached.rb:19:in `'
from (irb):1:in `require'
from (irb):1
from /usr/bin/irb:12:in `
'


Finally, I found this README where I realized I could install it as a gem:
sudo gem install memcached --no-rdoc --no-ri

This gave a ton of 'make' output, ending with this error:

...
rlibmemcached_wrap.c:12375: warning: format not a string literal and no format arguments
rlibmemcached_wrap.c:12380: warning: format not a string literal and no format arguments
rlibmemcached_wrap.c:12385: warning: format not a string literal and no format arguments
rlibmemcached_wrap.c: In function ‘_wrap_memcached_generate_hash_rvalue’:
rlibmemcached_wrap.c:12415: warning: format not a string literal and no format arguments
rlibmemcached_wrap.c: In function ‘Init_rlibmemcached’:
rlibmemcached_wrap.c:13285: warning: implicit declaration of function ‘sasl_client_init’
rlibmemcached_wrap.c:13285: error: ‘SASL_OK’ undeclared (first use in this function)
make: *** [rlibmemcached_wrap.o] Error 1


Gem files will remain installed in /var/lib/gems/1.9.1/gems/memcached-0.19.5 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/memcached-0.19.5/ext/gem_make.out

So I tried installing it in my home directory instead of globally for my machine:
gem install memcached --no-rdoc --no-ri

Then I have to do something different with the gems so that my default 'irb' session will find it:
export GEM_HOME=/home/trent/.gem/ruby/1.9.1

I expect this will make it so no other system-level gems will work. Ah, well. At least I can get their example to work.

No comments: