Skip to content

Commit d67b83e

Browse files
committed
Respect users configured IRB.conf[:IRB_NAME]
If a user has configured `IRB_NAME` in their IRB configuration, Rails is overriding it. This PR makes it so the `IRB_NAME` is only set if it is not the default, similar to the way the `PROMPT_MODE` is set.
1 parent aa66aec commit d67b83e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

railties/lib/rails/commands/console/irb_console.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def start
8787

8888
env = colorized_env
8989
prompt_prefix = "%N(#{env})"
90-
IRB.conf[:IRB_NAME] = @app.name
90+
# Respect user's configured irb name.
91+
IRB.conf[:IRB_NAME] = @app.name if IRB.conf[:IRB_NAME] == "irb"
9192

9293
IRB.conf[:PROMPT][:RAILS_PROMPT] = {
9394
PROMPT_I: "#{prompt_prefix}:%03n> ",

railties/test/application/console_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,21 @@ class User
242242
write_prompt "User.new.respond_to?(:age)", "=> true"
243243
end
244244

245+
def test_console_respects_user_defined_irb_name
246+
irbrc = Tempfile.new("irbrc")
247+
irbrc.write <<-RUBY
248+
IRB.conf[:IRB_NAME] = "jarretts-irb"
249+
RUBY
250+
irbrc.close
251+
252+
options = "-e test"
253+
spawn_console(options, env: { "IRBRC" => irbrc.path })
254+
255+
write_prompt "123", prompt: "jarretts-irb(test):002> "
256+
ensure
257+
File.unlink(irbrc)
258+
end
259+
245260
def test_console_respects_user_defined_prompt_mode
246261
irbrc = Tempfile.new("irbrc")
247262
irbrc.write <<-RUBY

0 commit comments

Comments
 (0)