Nyaplot does not generate any plot in iruby running in jupyterhub

I am trying to customize Ruby core within an existing multi-user jupyterhub installation. It works in all my tests, except that the plots produced by nyaplot (the only print package I could find working inside iruby) do not appear in the notebook. For example, the following code (from one of the Nyaplot tutorials) gives no errors (even in the syslog file), but no graph:

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

      

History:

This is how I set up iruby to run in jupyterhub. I give the whole process so that (a) you can notice if something is missing, and (b) so you know that if you say something like "add [this] to the Gemfile", you have to tell me where to put the Gemfile, since jupyterhub doesn't run from a separate directory.

OS - CentOS 7.3. Since its default ruby ​​version is too old to run iruby, I installed the ruby ​​version 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 sciruby-full component doesn't work with 2.4 yet.) After installation, the post says ruby ​​is installed in / opt / rubies / ruby ​​2.3.4 ...

Next comes the package installations.

I needed to make sure nothing was installed in my home directory because on a multi-user system, other users do not have access to my home directory files. I am listing below all the packages that I ended up installing to try and fix 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 the installation of the iruby kernel in jupyterhub.

After viewing the results " iruby register --force

", I created a file /usr/local/share/jupyter/kernels/ruby

:

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

      

To / 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, it all works with basic ruby: I can run the code I found in the Ruby tutorials. The only thing I don't get is the plots. All other jupyterhub kernels I have installed (e.g. python, SageMath, Julia) have no plotting problems.

Any ideas?

+4


source to share


1 answer


It works correctly with iruby-kernel 0.3 (ruby 2.6.3)



enter image description here

0


source







All Articles