Introduction

Jupyter Lab is the next-generation web-based user interface for Jupyter project. I first encountered The Jupyter project back when it was know as IPython notebooks and used it for hacking on python projects.

I was pleasantly surprised to learn that the Jupyter project also supports kernels other than Python with Ruby being one of them. This post covers installing the iRuby kernel for use with Jupyter Notebooks.

This post assumes that rbenv and ruby 2.6.0 is already installed. You can follow this post to get them installed.

For reference the following software will be used in this post.

  • Python - 3.6.7
  • Jupyter Lab - 4.4.0
  • rbenv - 1.1.1-39-g59785f6
  • Ruby - 2.6.0
  • iRuby - 0.3

Dependencies

Install the required dependencies.

cmd

sudo apt install libzmq3-dev libczmq-dev
          

Jupyter Lab Install

Create a virtual environment and Install Jupyter Lab.

cmd

mkdir -p /home/bradmin/Documents/code/python/jupyter-lab
cd /home/bradmin/Documents/code/python/jupyter-lab
source .venv/bin/activate
pip install jupyterlab
            

Install iRuby

Create a ruby environment and install iRuby and its dependencies.

cmd

mkdir -p /home/bradmin/Documents/code/python/jupyter-lab/ruby
cd /home/bradmin/Documents/code/python/jupyter-lab/ruby
rbenv local 2.6.0
gem install bundler cztop iruby
            

Now register the Ruby kernel with Jupyter Lab.

cmd

iruby register --force
        

Testing Testing 123..

Start Jupyter lab.

cmd

jupyter-lab
        

Your browser will open, select the Ruby Kernel notebook.

Summary

Ruby does not have a nice interactive terminal, it has IRB which is very bare bones and does not have a great user experience. Using Jupyter Lab with a Ruby kernel is a nice way to hack on a Ruby project with a user friendly interface.

Update: Ruby does have pry which is very nice alternative to IRB.

Updated: 4th October 2019

ruby jupyter