SciRuby / iruby

Official gem repository: Ruby kernel for Jupyter/IPython Notebook
https://github.com/SciRuby/iruby
MIT License
900 stars 28 forks source link

Using IRuby.input or IRuby.form hangs Kernel #320

Open Xasin opened 2 years ago

Xasin commented 2 years ago

Hello everyone!

I am having a problem using the IRuby Jupyter kernel on my laptop. The problem: Immediately after using the IRuby.input or IRuby.form command, the actual form does not render properly. A warning is also shown: image

In addition to this, the Kernel now hangs until restarted. Clicking "done" has no effect. Hitting enter on the form panels causes the browser to reload the website.

The same warning is shown when using IRuby.input, and the behaviour on hitting enter is the same.

It appears that the JS Snippet responsible for registering the form submission fails to execute properly.

Please note that the python3 input function works perfectly fine. I tested this in Chromium and Firefox, same behaviour in both browsers.

I installed it according to the recommended installation methods given on this GitHub page. Versions:

I had to manually install the erector gem as it seems to be a missing dependency when installing the iruby gem.

I would love to be able to use this for some of my own work, but having an input panel would be incredibly helpful, if not outright part of the base capabilities that I expect from this. I hope this issue can be resolved quickly.

Kind regards, Xasin

EDIT: I initially thought the kernel hangs, but it seems it really is just waiting on the message of the Jupyter Notebook to come back. As the form can never be submitted, the kernel then hangs at this cell indefinitely, but it CAN be interrupted, and if the statement is wrapped within a Timeout.timeout, it does abort execution after the timeout.

Still - having inputs would be very, very useful.

kojix2 commented 2 years ago

Hello.

@kylekyle Do you have any idea about this issue?

Xasin commented 2 years ago

I just noticed that this problem only occurs in jupyter lab

If I do the same within a Jupyter notebook on the same machine and same versions, it works fine.

Maybe the Jupyter lab deprecated a JavaScript function to access the last executed cell, which would prevent a JS script from accessing the input forms of the last cell and add the onSubmit handlers.

I would prefer to use Jupyter Lab, as the interactive ruby shell and the ability to drag and drop cells between shell and notebook would be nice.

niebaopeng commented 2 years ago

I try to use IRuby.input first I encounter the erector error, then I install it. After that, "NameError: uninitialized class variable @@schemes in URI" is here Python 3.10.2 (main, Mar 13 2022, 09:07:14) [GCC 10.2.1 20210110] IRuby 0.7.4 (with ffirzmq session adapter) jupyter notebook classic 6.4.8-0d94979

topofocus commented 1 year ago

Confirmed. The Error is still there.

NameError: uninitialized class variable @@schemes in URI
/usr/share/rvm/gems/ruby-3.2.0/gems/data_uri-0.1.0/lib/data_uri/uri.rb:64:in `<module:URI>'
/usr/share/rvm/gems/ruby-3.2.0/gems/data_uri-0.1.0/lib/data_uri/uri.rb:1:in `<top (required)>'
/usr/share/rvm/gems/ruby-3.2.0/gems/data_uri-0.1.0/lib/data_uri.rb:5:in `require'
/usr/share/rvm/gems/ruby-3.2.0/gems/data_uri-0.1.0/lib/data_uri.rb:5:in `<top (required)>'
/usr/share/rvm/gems/ruby-3.2.0/gems/iruby-0.7.4/lib/iruby/input/file.rb:1:in `require'
/usr/share/rvm/gems/ruby-3.2.0/gems/iruby-0.7.4/lib/iruby/input/file.rb:1:in `<top (required)>'
/usr/share/rvm/gems/ruby-3.2.0/gems/iruby-0.7.4/lib/iruby/input/autoload.rb:19:in `require'
/usr/share/rvm/gems/ruby-3.2.0/gems/iruby-0.7.4/lib/iruby/input/autoload.rb:19:in `<top (required)>'
/usr/share/rvm/gems/ruby-3.2.0/gems/iruby-0.7.4/lib/iruby/input.rb:18:in `require'
/usr/share/rvm/gems/ruby-3.2.0/gems/iruby-0.7.4/lib/iruby/input.rb:18:in `form'
(irb):in `<top (required)>'

Anybody with a hint to fix it?

ashgkwd commented 5 months ago

This error can be fixed in the data_uri gem by merging this PR https://github.com/dball/data_uri/pull/15

I tried modifying the codes of the data_uri gem locally and the changes mentioned in the above PR fixes this issue. Either @dball can merge this PR OR @SciRuby needs to use well maintained gem instead of data_uri