A long-lived project that still receives updates
A Ruby kernel for Jupyter environment. Try it at try.jupyter.org.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies

Development

Runtime

~> 0.1
>= 3.3.1
~> 1.11
>= 0
 Project Readme

IRuby

Gem Version Build Status Binder

IRuby is a Ruby kernel for Jupyter project.

Try IRuby

You can try IRuby with a sample notebook on Binder (the same link as the banner placed above):

https://mybinder.org/v2/gh/RubyData/binder/master?filepath=ruby-data.ipynb

The following URL launches JupyterLab directly on Binder.

https://mybinder.org/v2/gh/RubyData/binder/master?filepath=../lab

Installation

Requirements

If both ffi-rzmq and cztop are installed, ffi-rzmq is used. If you prefer cztop, set the following environment variable.

export IRUBY_SESSION_ADAPTER="cztop"
  • Pry, if you want to use Pry instead of IRB for the code execution backend
  • If you want to install the development version of IRuby from the source code, try specific_install.
gem specific_install https://github.com/SciRuby/iruby

Ubuntu

Install Jupyter.

Ubuntu 17+

sudo apt install libtool libffi-dev ruby ruby-dev make
sudo apt install libzmq3-dev libczmq-dev

gem install ffi-rzmq
gem install iruby --pre
iruby register --force

Ubuntu 16

CZTop requires CZMQ >= 4.0.0 and ZMQ >= 4.2.0. The official packages for Ubuntu 16.04 don't satisfy these version requrements, so you need to install from source.

sudo apt install libtool libffi-dev ruby ruby-dev make
sudo apt install git libzmq-dev autoconf pkg-config
git clone https://github.com/zeromq/czmq
cd czmq
./autogen.sh && ./configure && sudo make && sudo make install

gem install cztop
gem install iruby --pre
iruby register --force

Windows

Install git and Jupyter. DevKit is necessary for building RubyGems with native C-based extensions.

Install ZeroMQ.

pacman -S mingw64/mingw-w64-x86_64-zeromq
gem install ffi-rzmq
gem install iruby --pre
iruby register --force

macOS

Install ruby with rbenv or rvm. Install Jupyter.

Homebrew

brew install automake gmp libtool wget
brew install zeromq --HEAD
brew install czmq --HEAD
# export LIBZMQ_PATH=$(brew --prefix zeromq)/lib
# export LIBCZMQ_PATH=$(brew --prefix czmq)/lib
# gem install cztop
gem install ffi-rzmq
gem install iruby --pre
iruby register --force

MacPorts

If you are using macports, run the following commands.

port install libtool autoconf automake autogen
gem install ffi-rzmq
gem install iruby

Docker

Try RubyData Docker Stacks. Running jupyter notebook:

docker run -p 8888:8888 rubydata/datascience-notebook

Installation for JRuby

You can use Java classes in your IRuby notebook.

  • JRuby version >= 9.0.4.0
  • cztop gem
  • iruby gem

After installation, make sure that your env is set up to use jruby.

$ env ruby -v

If you use RVM, it is enough to switch the current version to jruby.

If you have already used IRuby with a different version, you need to generate a new kernel:

$ iruby register --force

Backends

There are two backends: PlainBackend and PryBackend.

  • PlainBackend is the default backend. It uses IRB.
  • PryBackend uses Pry.

You can switch the backend to PryBackend by running the code below.

IRuby::Kernel.instance.switch_backend!(:pry)

Notebooks

Take a look at the example notebook and the collection of notebooks which includes a Dockerfile to create a containerized installation of iruby and other scientific gems. You can find the prebuild image at dockerhub.

Contributing

Contributions to IRuby are very welcome.

To former contributors

In February 2021, IRuby became the canonical repository and is no longer a fork from minrk/iruby. Please fork from this repository again before making pull requests.

License

Copyright (c) IRuby contributors and the Ruby Science Foundation.

Licensed under the MIT license.