0
votes

I noticed in IRB if you type:

Readline::HISTORY << 'something = ->() { 5 }'

And then when you press the up arrow key on your keyboard, you will see your code something = ->() { 5 }. You then press enter to execute the code...

This is true for older Rubies. For Ruby 2.7 though, it's not working. It isn't raising any kind of error, the history doesn't work at all when you press the up arrow key!

In fact I have patched the REPL to fit my own needs. It writes the histories to a file, and then loads them up when you load up the irb shell (just like the MRuby's REPL "mirb"). Here's the patched irb.

Is there a way I to get the patched-irb work with Ruby 2.7?

1

1 Answers

2
votes

Is there a way I to get the patched-irb work with Ruby 2.7?

Keeping patched versions of software working with new versions is always tricky, especially if you're making assumptions about how the guts work.

It's harder when your patched version has no relationship to the original. You have made your own irb repository that has no relationship to the original irb and so can't use version control to keep up to date.

Instead, make the fork of the original repository and make your patches in the fork. Then by pulling from the original upstream repository you can better keep up to date with changes, make sure everything still works, and find out exactly at what upstream version your patches failed.

Fortunately irb was recently spun off into its own gem. Fork that gem, make your patches in that fork, and stay up to date by periodically pulling changes from the upstream gem.

Then submit your patches upstream as pull requests. If they're merged they will be kept working as part of the larger project. It's no longer your job to maintain them separately.