iRuby kernel keeps getting killed

936 views Asked by At

I am Ruby with Homebrew on macOS Sierra 10.12.3. I installed jupyter with pip install and iruby with gem install

When I run iruby notebook the server starts fine but while creating a new notebook Kernel is always killed with following log.

/usr/local/lib/ruby/gems/2.4.0/gems/iruby-0.2.9/lib/iruby/kernel.rb:18:in `initialize': uninitialized constant IRuby::Kernel::Session (NameError)
    from /usr/local/lib/ruby/gems/2.4.0/gems/iruby-0.2.9/lib/iruby/command.rb:70:in `new'
    from /usr/local/lib/ruby/gems/2.4.0/gems/iruby-0.2.9/lib/iruby/command.rb:70:in `run_kernel'
    from /usr/local/lib/ruby/gems/2.4.0/gems/iruby-0.2.9/lib/iruby/command.rb:34:in `run'
    from /usr/local/lib/ruby/gems/2.4.0/gems/iruby-0.2.9/bin/iruby:5:in `<top (required)>'
    from /usr/local/bin/iruby:22:in `load'
    from /usr/local/bin/iruby:22:in `<main>'

I have seen other question but there the error message is different.

3

There are 3 answers

2
J.Bacon On

The iRuby documentation at github suggests using Anaconda and setting your Ruby environment to 2.4.1 using rbenv. I had the same issue when experimenting with the iRuby kernel.

From the Readme:

Mac

I recommend an installation using Anaconda.

After that, run the following commands.

brew install rbenv automake gmp libtool wget
rbenv install 2.4.1
rbenv global 2.4.1  
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
brew install zeromq
brew install czmq --HEAD
gem install cztop iruby
iruby register --force
0
J.Bacon On

I am not sure why the kernel is dying but I suspect it has something to do with the zeromq socket interface. On My Mac I have confirmed the following is working:

Perhaps brew, ruby and python installed a separate zeromq instance.

IRuby 0.2.9
Ruby 2.1.0
Homebrew 1.1.12

I have not had any time to investigate it.

0
DBrown On

I found that this particular error came up when running iRuby in a project folder with a Gemfile, and mentioned in this issue. You may also see a warning when starting iruby to run the register command, as well as add your libraries to the Gemfile.

Add both iruby and ffi-rzmq in your Gemfile:

gem 'iruby'
gem 'ffi-rzmq'

then run:

$ bundle install

After all is installed, go ahead and run iruby again:

$ iruby notebook

After starting iruby you should see a log without the uninitialized constant IRuby::Kernel::Session (NameError) error, and a kernel that does not die.

Even though you may not need to, if for some reason you continue to have issues it may be worth re-registering the kernel after the bundle:

$ iruby register --force

Hope this helps someone!