IRB leaking out Reline changes globally

Open
#1,048 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
cli

Research direction

Start by reproducing the issue with the provided IRB.start and Reline.readline sequence, then trace how IRB changes Reline state during and after the session. Compare Reline settings before and after quitting IRB, including autocompletion and core state. Done means the original Reline settings remain unchanged after IRB.start returns.

Written by the indexing model from the issue text.

Description

Description

Calling to IRB.start results in IRB leaking out Reline changes globally.

Minimal Reproducible Example

require 'reline'
require 'irb'

::Reline.autocompletion = false

line = ::Reline.readline('PROMPT >> ', false)

IRB.start

line = ::Reline.readline('PROMPT >> ', false)

Current Workaround

I'm unsure if there's any other potential settings being changed. Here's what I have so far:

config = { autocompletion: Reline.autocompletion, core: Reline.core.dup }
IRB.start
Reline.autocompletion = config[:autocompletion]
Reline.instance_variable_set(:@core, @current_config[:core])

Expected Behaviour

I would expect that changes to Reline performed by IRB do not persist after quitting out of the IRB session.
My Reline changes and settings should remain what the were before and after.

Result of irb_info

irb(main):001> irb_info
Ruby version: 3.3.6
IRB version: irb 1.14.1 (2024-09-25)
InputMethod: RelineInputMethod with Reline 0.5.12
Completion: Autocomplete, RegexpCompletor
RUBY_PLATFORM: x86_64-linux
LANG env: en_GB.UTF-8
East Asian Ambiguous Width: 1

Terminal Emulator

Konsole. This happens on a Mac as well with the default terminal.

Setting Files

Are you using ~/.irbrc and ~/.inputrc?
-> No

Dominant language
Ruby
Stars
477
Forks
165
Avg merge
1d 19h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/irb

All issues in ruby/irb

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.