Skip to content

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 7, 2024

Before v1.12, IRB avoids loading ~/.irbrc if the project folder has a .irbrc file. So to avoid loading dev's ~/.irbrc, cfe908c added an empty irbrc fixture as a workaround.

However, because IRB v1.12 starts loading ~/.irbrc even if the project folder has a .irbrc file, the workaround no longer works.

This commit removes the workaround and uses altering HOME environment variable to avoid loading .irbrc from devs' home directory instead.

st0012 added 2 commits March 7, 2024 13:46
Before v1.12, IRB avoids loading `~/.irbrc` if the project folder has
a `.irbrc` file. So to avoid loading dev's `~/.irbrc`, cfe908c added an
empty irbrc fixture as a workaround.

However, because IRB v1.12 starts loading `~/.irbrc` even if the project
folder has a `.irbrc` file, the workaround no longer works.

This commit removes the workaround and uses altering `HOME` environment
variable to avoid loading `.irbrc` from devs' home directory instead.
@nobu
Copy link
Member

nobu commented Mar 9, 2024

Don't IRBRC and XDG_CONFIG_HOME need to be set or cleared too?


describe "Binding#irb" do
before :each do
@env_home = ENV["HOME"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@env_home = ENV["HOME"]
@envs = ["IRBRC", "XDG_CONFIG_HOME", "HOME"].map {|e| [e, ENV.delete(e)]}.to_h

end

after :each do
ENV["HOME"] = @env_home
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ENV["HOME"] = @env_home
ENV.update(@envs)

irbrc_fixture = fixture __FILE__, "irbrc"

out = IO.popen([{"IRBRC"=>irbrc_fixture}, *ruby_exe, irb_fixture], "r+") do |pipe|
out = IO.popen([*ruby_exe, irb_fixture], "r+") do |pipe|
Copy link
Member

Choose a reason for hiding this comment

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

Rather how about to change states only in the IO.popen-ed process?

Suggested change
out = IO.popen([*ruby_exe, irb_fixture], "r+") do |pipe|
dir = CODE_LOADING_DIR
envs = {"IRBRC" => nil, "XDG_CONFIG_HOME" => nil, "HOME" => dir}
out = IO.popen([envs, *ruby_exe, irb_fixture, chdir: dir], "r+") do |pipe|

@eregon
Copy link
Member

eregon commented Mar 11, 2024

Could we use irb's -f flag or similar to skip irbrc's?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants