Skip to content

Skip re-setup when creating a child session - #850

Merged
st0012 merged 1 commit into
ruby:masterfrom
nunosilva800:625-irbrc-file-ensure-loads-only-once
Feb 1, 2024
Merged

st0012 merged 1 commit into
ruby:masterfrom
nunosilva800:625-irbrc-file-ensure-loads-only-once

Conversation

@nunosilva800

@nunosilva800 nunosilva800 commented Jan 31, 2024 •

Copy link
Copy Markdown
Contributor

When binding.irb is called, the new session is setup without command line arguments:

irb/lib/irb.rb

Lines 1516 to 1517 in a641746

# Setup IRB with the current file's path and no command line arguments
IRB.setup(source_location[0], argv: [])

This means that the child session does not respect the parent command line arguments.
Therefore when using $ irb -f (to ignore RC file), and opening a child session with binding.irb, the new session will load the RC file (if it exists).

See more in:

This solution is different from:

  1. It does not call IRB.setup when creating a new IRB instance, unless the current session was never initialized
  2. Adds IRB.initialized? to know if the conf init was called at least once

Closes #625

@nunosilva800
nunosilva800 force-pushed the 625-irbrc-file-ensure-loads-only-once branch 2 times, most recently from c533865 to e3ece31 Compare February 1, 2024 10:09
@nunosilva800
nunosilva800 force-pushed the 625-irbrc-file-ensure-loads-only-once branch from e3ece31 to ee82037 Compare February 1, 2024 10:12
@nunosilva800
nunosilva800 marked this pull request as ready for review February 1, 2024 10:12
@st0012 st0012 added the bug Something isn't working label Feb 1, 2024

@st0012 st0012 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IRBRC file is loaded every time ruby reaches binding.irb

2 participants