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

Deprecate multi-irb feature #653

Open
st0012 opened this issue Jul 22, 2023 · 8 comments
Open

Deprecate multi-irb feature #653

st0012 opened this issue Jul 22, 2023 · 8 comments
Labels
enhancement New feature or request
Milestone

Comments

@st0012
Copy link
Member

st0012 commented Jul 22, 2023

Plan

  • Print deprecation warnings on these commands: irb, jobs, fg, and kill in the next minor release
  • Completely remove those commands in v2.0.0

Reasons

  • It's concept highly overlaps with workspace commands like chws, pushws...etc.
  • It spawns a new thread for every new new session, which conflicts with the upcoming irb-debug integration
  • But most importantly, we can't find any practical use for this feature and the cost of maintaining its compatibility with other features is high

Feedback wanted

If you use the multi-irb feature and don't want to see it deprecated from IRB, please leave a comment below to explain your use case of it. It will help us assess this plan.

@st0012 st0012 added the enhancement New feature or request label Jul 22, 2023
@st0012 st0012 added this to the v2.0.0 milestone Aug 7, 2023
@zenspider
Copy link

Please consider reusing the old command names. chws is just... not good.

@kml
Copy link

kml commented Feb 15, 2024

Hi. I find irb command to be useful as an equivalent of pry cd.
For example when debugging session starts in irb console (like rails console - testing on staging case), not by putting binding.irb in the tested file.

bin/rails console

# assume it's part of the application
class Greeter
  def hello = "Hello, World!"
end

g = Greeter.new
irb g # <-----------------
Multi-irb commands are deprecated [...]
irb#1(#<Greeter:0x00007faa7b850188>):001> hello
=> "Hello, World!"

Ctrl-D to get back.

UPDATE: OK, just realized that it's exactly what chws is for 😉 Only more complex to remember the syntax:

pushws cwws
# => [main]
chws g
# => #<Greeter:0x00007f29077f5c38>
hello
# => "Hello, World!"
popws
# => []

Is there a way to go back without having first to push current workspace to the stack?

pry example:

[3] pry(main)> cd g
[4] pry(#<Greeter>):1> hello
# => "Hello, World!"
[5] pry(#<Greeter>):1> cd ..
[6] pry(main)> 

My impression is that cd, cd .. is the human-friendly interface, while workspace commands are generally building blocks of it exposed to the user (missed one layer of abstraction).

https://github.com/ruby/irb?tab=readme-ov-file#commands

@st0012
Copy link
Member Author

st0012 commented Jun 16, 2024

@kml Thanks for the feedback 🙂 I'm adding a simpler cd command in #971

@jwkoelewijn
Copy link

I love how this got implemented.... Now whenever I try to assign to an instance variable with the name jobs it now prints a message and doesn't actually create the var... brilliant.

@ozydingo
Copy link

This implementation is a bit overly aggressive. As @jwkoelewijn points out, it breaks any code we might type or copy-paste that uses a jobs instance variable:

worker (local) > jobs = Job.all
Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
#0->irb on main (#<Thread:0x0000ffff8239a7b0 run>: running)
=> nil
worker (local) > jobs
Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
#0->irb on main (#<Thread:0x0000ffff8239a7b0 run>: running)
=> nil

Is there a way we can not break assignment to a variable named jobs?

@tompng
Copy link
Member

tompng commented Aug 1, 2024

Usability problem of local variable and command is fixed in #961 and released

# irb -v
irb 1.14.0 (2024-07-06)
# irb
irb(main):001> jobs = [1, 2, 3]
=> [1, 2, 3]
irb(main):002> jobs
=> [1, 2, 3]
irb(main):003> 

@jwkoelewijn
Copy link

Sweet, thanks! 🙌🏼

@jdelStrother
Copy link

jdelStrother commented Oct 22, 2024

Something I miss without being able to just run irb everywhere is being able to inspect something that only exists for the duration of a block - eg:

irb(main):002:0> File.open("/etc/hosts") { |f| irb f }
irb#1(#<File:0x000055be023ef240>):001:0> self.size
=> 174

and then being able to iteratively experiment with methods on the object yielded to the block.
(pretending for the moment that File.open doesn't support a blockless variant)

Is there an equivalent version that works without multi-irb?

[EDIT: Oh, maybe I should just be using binding.irb ?

irb(main):001> File.open("/etc/hosts") { |f| binding.irb }
irb(main):001> f.size
=> 1063

]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

7 participants