5

I'm trying to set up a Ruby kernel within an existing multi-user jupyterhub installation. It works in all of my tests, except that plots created by nyaplot (the only plotting package I could find that works within iruby) don't show up in the notebook. For example, the following code (from one of the Nyaplot tutorials) gives no error (not even in the syslog file) but no plot:

require 'nyaplot'
plot = Nyaplot::Plot.new
sc = plot.add(:scatter, [0,1,2,3,4], [-1,2,-3,4,-5])
color = Nyaplot::Colors.qual
sc.color(color)
plot.show # show plot on IRuby notebook

Background:

Here's how I set up iruby to run in jupyterhub. I'm giving the entire process so (a) you can spot if anything is missing, and (b) so you know that if you say something like "add [this] to the Gemfile" you're going to have to tell me where to put the Gemfile, since jupyterhub is not running iruby out of a particular directory.

The OS is CentOS 7.3. Since its default version of ruby is too old to run iruby, I installed a version of ruby using ruby-install:

wget -O ruby-install-0.6.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.6.1.tar.gz
tar -xzvf ruby-install-0.6.1.tar.gz 
cd ruby-install-0.6.1
make
make install
ruby-install ruby 2.3.4

(I used ruby 2.3, instead of 2.4, because it turned out that at least one component of sciruby-full doesn't work with 2.4 yet.) After the installation, a message says that ruby is installed in /opt/rubies/ruby-2.3.4.

Next come the package installations.

I had to make sure that nothing was installed in my home directory, because in a multi-user system the other users don't have access to my home directory's files. I'm listing below all the packages I eventually installed to try to solve this problem:

export RUBYDIR=/opt/rubies/ruby-2.3.4
export PATH=${RUBYDIR}/bin:$PATH
export LD_LIBRARY_PATH=${RUBYDIR}/lib:$LD_LIBRARY_PATH
export GEM_HOME=${RUBYDIR}
export GEM_PATH=${RUBYDIR}
gem install --no-user-install cztop rbczmq iruby
gem install --no-user-install pry pry-doc awesome_print gnuplot rubyvis nyaplot
gem install --no-user-install sciruby-full
gem install --no-user-install zeromq ffi-rzmq gnuplotrb

Next comes installing the iruby kernel into jupyterhub.

After looking at the results of "iruby register --force",
I created the file /usr/local/share/jupyter/kernels/ruby:

{"argv":[
         "/usr/local/bin/jupyter-ruby-env.sh",
         "{connection_file}"
          ],
 "display_name":"Ruby",
 "language":"ruby"
}

In /usr/local/bin/jupyter-ruby-env.sh:

#!/usr/bin/bash -l                                                                                                                                    
export RUBYDIR=/opt/rubies/ruby-2.3.4
export PATH=${RUBYDIR}/bin:$PATH
export LD_LIBRARY_PATH=${RUBYDIR}/lib:$LD_LIBRARY_PATH
export GEM_HOME=${RUBYDIR}
export GEM_PATH=${RUBYDIR}
exec ${RUBYDIR}/bin/iruby kernel $@

As I said, all of this works as far as basic ruby is concerned: I can run code I found in the Ruby tutorials. The only thing I don't get are plots. All of the other jupyterhub kernels I've installed (e.g., python, SageMath, Julia) have no problems plotting.

Any ideas?

user3666197
  • 1
  • 6
  • 50
  • 92
  • "I'm a Ruby n00b."? Don't say that. We don't care what your expertise is, we want you to research your problem, try many times, then write a clear and concise question. See "[How much research effort is expected of Stack Overflow users?](http://meta.stackoverflow.com/questions/261592)" and "[Grovelling is not a substitute for doing your homework](http://catb.org/esr/faqs/smart-questions.html#idm46227255999488)". It's obvious you tried, but the approach could be improved. – the Tin Man Jun 14 '17 at 21:47
  • I did do my homework, or at least I thought I did. The only other reference I could find for a similar problem did not seem to offer a solution I could use, for the reason I noted above: https://groups.google.com/forum/#!topic/sciruby-dev/wcnFC824nJg There are no error messages in any log I could find in my system, no handle I could use to trace execution, no other behavior I could see that would be a hook into tracing what's wrong. Is there some other area of research that I've overlooked? – William Seligman Jun 15 '17 at 15:31

1 Answers1

2

I don't know much about JupyterHub. But Nyaplot has not been updated for several years.

If you want to generate plot in iruby, try these projects.

Following projects are experimental.

kojix2
  • 806
  • 7
  • 18