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

Skip re-setup when creating a child session #850

Merged

Conversation

nunosilva800
Copy link
Contributor

@nunosilva800 nunosilva800 commented Jan 31, 2024

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
Copy link
Member

@st0012 st0012 left a comment

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!

@st0012 st0012 merged commit 06b2d00 into ruby:master Feb 1, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

IRBRC file is loaded every time ruby reaches binding.irb
2 participants