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

Multiple executions in IRB causes error #45

Open
rvs314 opened this issue Apr 14, 2023 · 6 comments
Open

Multiple executions in IRB causes error #45

rvs314 opened this issue Apr 14, 2023 · 6 comments

Comments

@rvs314
Copy link

rvs314 commented Apr 14, 2023

When running a simple example in IRB, I get a weird result where running a program multiple times causes the second invocation to make an empty window.

Here's an example interaction:

irb(main):001:0> require 'glimmer-dsl-libui'
=> true
irb(main):006:0> include Glimmer
=> Object
irb(main):008:0> window('test') {
irb(main):010:1*     button('Click Me')
irb(main):011:1>   }.show # window displays correctly, call is blocking
=> nil
irb(main):014:0> window('test') {
irb(main):015:1*     button('Click Me')
irb(main):016:1>   }.show # window opens, but does not update; call is non-blocking
=> nil
irb(main):017:0> # repl is still live, but the window does not redisplay

This looks like an analogue of this issue in the underlying LibUI bindings.

I'm using Debian GNU/Linux 6.1.0-6-amd64, ruby 3.1.2p20, XOrg Version: 1:7.7+23 and dwm-6.2.

@AndyObtiva
Copy link
Owner

Please use girb instead (Glimmer IRB):
https://github.com/AndyObtiva/glimmer-dsl-libui#girb-glimmer-irb

It automatically requires the glimmer-dsl-libui library and includes Glimmer for you.

Also, it allows opening a window multiple times with no practical problem.

The only known issue it suffers from is when you close the window (via x button or by quitting), it keeps the window open, but if you re-open the window with different title/content, the new title/content shows up, so it's not a problem practically speaking.

Otherwise, you have another option for playing around with Glimmer DSL for LibUI applications. Start the Glimmer Meta-Example (via ruby -r glimmer-dsl-libui -e "require 'examples/meta_example'" command), which lets you start multiple applications from the same code editor with no problem.:
https://github.com/AndyObtiva/glimmer-dsl-libui#examples

I believe both options above should address your concerns/goals, so I am closing this issue. But, if you still have issues or you have other comments to share, please reply or even re-open the issue if needed.

@rvs314
Copy link
Author

rvs314 commented Apr 24, 2023

@AndyObtiva

Sorry for resurrecting this, but I don't think this fixes my issue. At least, repeating the issue in girb causes the same error. When it starts, I get the following messages:

Gtk-Message: 14:03:38.638: Failed to load module "xapp-gtk3-module"
irb: warn: can't alias exit from irb_exit.
irb: warn: can't alias quit from irb_exit.

Typing in the example I gave above, the second invocation (even with new contents) doesn't render.

I am able to start multiple applications from the meta-example viewer, but it doesn't really solve the issue of not being able to use them in IRB.

@AndyObtiva
Copy link
Owner

AndyObtiva commented Apr 24, 2023

You do not have to be sorry for resurrecting this. However, this might just be a Linux-only issue as it works fine on my Mac. I didn't think of testing on Linux. I'm sorry about this. I will take a look when I get a chance.

By the way, by "should address your concerns/goals", I meant addressing the ultimate goal behind using both IRB and Meta-Example, which is to be able to prototype Ruby Glimmer apps quickly. To me personally, the Meta-Example is good enough in addressing that goal/concern to the point that I rarely use IRB. Sometimes, it is a good idea to step back and realize that a certain tool is not needed if there are better alternatives that address the same goals behind it, and I sometimes have to discipline myself against using a certain popular tool (letting go of attachment to it) if I have other more effective tools at my disposal. Otherwise, I would be hurting productivity in finishing apps for customers unnecessarily. But, perhaps there is a goal for why to use IRB that the Meta-Example does not address, like being able to go up in the command history to re-run previous commands. So, I will still look into the issue on Linux to figure out if there is a fix for it. And, I hope that the Meta-Example could address part of your goal/concern in the meantime until the IRB issue is resolved if possible.

@AndyObtiva AndyObtiva reopened this Apr 24, 2023
@rvs314
Copy link
Author

rvs314 commented Apr 25, 2023

I didn't think of testing on Linux. I'm sorry about this. I will take a look when I get a chance.

Thanks - let me know if there's anything you want me to help/test on my end.

By the way, by "should address your concerns/goals", I meant addressing the ultimate goal behind using both IRB and Meta-Example, which is to be able to prototype Ruby Glimmer apps quickly. To me personally, the Meta-Example is good enough in addressing that goal/concern to the point that I rarely use IRB. Sometimes, it is a good idea to step back and realize that a certain tool is not needed if there are better alternatives that address the same goals behind it, and I sometimes have to discipline myself against using a certain popular tool (letting go of attachment to it) if I have other more effective tools at my disposal. Otherwise, I would be hurting productivity in finishing apps for customers unnecessarily.

That makes sense, each person works differently. The project I'm working on relies on communicating with several live connections which are best handled interactively, hence IRB.

@AndyObtiva
Copy link
Owner

That makes sense. Sounds good. I’ll let you know if I need any help. I haven’t had a chance to take a look on Linux yet, but I’ll let you know as soon as I have.

@AndyObtiva
Copy link
Owner

I was able to reproduce and confirm this issue on Linux.

I could not come up with a fix for it yet, but if I do in the future, you will hear of it here.

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

No branches or pull requests

2 participants