Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self no longer works with PlainBackend #303

Closed
UliKuch opened this issue May 31, 2021 · 7 comments
Closed

self no longer works with PlainBackend #303

UliKuch opened this issue May 31, 2021 · 7 comments
Assignees
Labels

Comments

@UliKuch
Copy link

UliKuch commented May 31, 2021

Hi!
Thanks for maintaining this Gem, I really enjoy using Jupyter notebooks with Ruby 🙂

Unfortunately, when using the PlainBackend in version 0.6 or 0.7 together with Ruby 3.0.1, I am having issues with the self object. It no longer evaluates to main, but to some other object:
grafik
As I verified by running the line in an irb session, the object seems to be the one created by

@main = TOPLEVEL_BINDING.eval("self").dup

Because of this, I can no longer include any modules inside a notebook.

When I remove the dup in the quoted line, everything seemed to work fine, but I am not sure if that breaks anything else.

Or am I missing some error on my part here? I am running my notebooks via the jupyter_on_rails gem, but the issue does not seem to lie there.

@kojix2
Copy link
Member

kojix2 commented May 31, 2021

Because of this, I can no longer include any modules inside a notebook.

Could you please explain more about this point?

@UliKuch
Copy link
Author

UliKuch commented Jun 1, 2021

Could you please explain more about this point?

If, inside a notebook, I try including a module, I receive a NoMethodError:

module Foo
  def bar
    puts "baz"
  end
end

include Foo
# NoMethodError: undefined method `include' for #<Object:0x00007f87fc58d960 @prompt={:PROMPT_I=>"3.0.1 :%03n > ", :PROMPT_S=>"3.0.1 :%03n%l> ", :PROMPT_C=>"3.0.1 :%03n > ", :PROMPT_N=>"3.0.1 :%03n?> ", :RETURN=>" => %s \n", :AUTO_INDENT=>true}>
# (irb):in `<main>'

In version 0.5, this used to work fine. And in any regular irb shell it works, too.

Extending the module instead seems to work though:

extend Foo
# #<Object:0x00007f87fc58d960 @prompt={:PROMPT_I=>"3.0.1 :%03n > ", :PROMPT_S=>"3.0.1 :%03n%l> ", :PROMPT_C=>"3.0.1 :%03n > ", :PROMPT_N=>"3.0.1 :%03n?> ", :RETURN=>" => %s \n", :AUTO_INDENT=>true}>

bar
# baz

@kojix2
Copy link
Member

kojix2 commented Jun 4, 2021

I see. I understand.
I was not aware of this problem.

@mrkn mrkn self-assigned this Jun 22, 2021
@mrkn mrkn added the bug label Jun 22, 2021
@mrkn
Copy link
Contributor

mrkn commented Jun 22, 2021

@UliKuch Thank you for reporting this issue. This is bug. I'll fix it asap.

@mrkn mrkn closed this as completed in d599c29 Jun 22, 2021
mrkn added a commit that referenced this issue Jun 22, 2021
@mrkn
Copy link
Contributor

mrkn commented Jun 22, 2021

@UliKuch Please try the version 0.7.2.

@kylekyle
Copy link
Collaborator

Works great! Thanks!

@UliKuch
Copy link
Author

UliKuch commented Jun 24, 2021

Including a module now works fine, thanks a lot @mrkn !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants