Ruby Binding


The Ruby binding (C extension) is available as a gem named zmq. For the alternate Ruby binding (FFI, works on JRuby and others), go to the ruby-ffi page for more information.

To install the ruby gem:

gem install zmq

If the gem installation complains that it cannot find libzmq or headers, simply pass the location of your libzmq installation to the gem install command:

gem install zmq -- --with-zmq-dir=/opt/local

On Windows I had to add the parameter for the libs. For example:

gem install zmq -- --with-zmq-dir=c:/src/zeromq-2.2.0 --with-zmq-lib=c:/src/zeromq-2.2.0/src/.libs

(note the extra -- are required)

This gem should work for both Ruby 1.8 and Ruby 1.9. Ruby threads are supported for Ruby 1.9 only (ZMQ calls will block the entire interpreter under Ruby 1.8, due to limitations of the zeromq C++ library and the Ruby 1.8 threading model).

Source Code

Source code can be found here:

To build the Ruby binding from the source code, first make sure that ØMQ is installed on the system. Then fetch the rbzmq code from the repository and do the following:

$ ruby extconf.rb 
$ make
$ make install

To test whether everything is all right try running the performance tests in perf subdirectory:

$ ruby local_lat.rb tcp:// 1 100


$ ruby ./remote_lat.rb tcp:// 1 100
message size: 1 [B]
roundtrip count: 100
mean latency: 44.875 [us]


The ruby bindings have rdoc/ri documentation that is installed along with the library. It is also available on the web at:

Additionally, have a look at performance tests in perf subdirectory.

Bug Reporting

Mailing list

Use generic ØMQ | mailing lists.