ruby

GDBM in Standard Lib missing or is it just me?


GDBM looks interesting, a kind of persistent Hash or a key-value store. However the example code does not run:

require 'gdbm'

results in this error:

cannot load such file -- gdbm (LoadError)

I'm using Ruby 1.9.3 on Ubuntu. Is the documentation wrong or is something wrong with my Ruby install?


Solution

  • GDBM is a library that provides an API to the GNU Database Library, which you might not have installed. Ruby Standard Library documentation advises it's available only if the underlying library is available on your system. (No point offering a library that doesn't connect to anything!) Install libgdbm3 with apt-get, confirm you have your library ('locate libgdbm' e.g.), and reinstall/update your ruby 1.9 to incorporate the library into your ruby.