Description
RVM defines their own custom IRB prompt called :RVM like this:
# rvm/scripts/irbrc.rb
# Set up the prompt to be RVM specific.
@prompt = {
:PROMPT_I => "#{rvm_ruby_string} :%03n > ", # default prompt
:PROMPT_S => "#{rvm_ruby_string} :%03n%l> ", # known continuation
:PROMPT_C => "#{rvm_ruby_string} :%03n > ",
:PROMPT_N => "#{rvm_ruby_string} :%03n?> ", # unknown continuation
:RETURN => " => %s \n",
:AUTO_INDENT => true
}
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RVM] = @prompt
IRB.conf[:PROMPT_MODE] = :RVM if IRB.conf[:PROMPT_MODE] == :DEFAULT
This fires whenever the ruby command is used. When I'm manually launching irb, this code executes upstream of my .irbrc file so I can override this :RVM prompt.
#714 recently fixed #713 so that the user's .irbrc would no longer affect tests. But this RVM config can still bleed through.
When tests run, I'm getting test failures like this in TestIRB::DebugCommandTest because the custom :RVM prompt is different than what is expected:
Failure: test_quit(TestIRB::DebugCommandTest):
</irb\(main\):001> next/> was expected to be =~
<"\r\n" +
"From: /var/folders/sk/mh9kbvhx4l924d3w9zlhj5zc0000gq/T/irb-20230917-82982-m6x5fv.rb @ line 1 :\r\n" +
"\r\n" +
" => 1: binding.irb\r\n" +
"\r\n" +
"next\r\n" +
"quit!\r\n" +
"3.2.1 :001 > 3.2.1 :001 > n3.2.1 :001 > ne3.2.1 :001 > nex3.2.1 :001 > next(rdbg:irb) next\r\n">.
/Users/username/dev/irb2/irb/test/irb/test_debug_cmd.rb:268:in `test_quit'
265: type "quit!"
266: end
267:
=> 268: assert_match(/irb\(main\):001> next/, output)
269: end
270:
271: def test_prompt_line_number_continues
Would it be possible for run_ruby_file to explicitly configure a :PROMPT_MODE to stop this RVM config from polluting tests? If I make this change, all tests pass:
--- a/test/irb/helper.rb
+++ b/test/irb/helper.rb
@@ -105,6 +105,9 @@ module TestIRB
cmd = [EnvUtil.rubybin, "-I", LIB, @ruby_file.to_path]
tmp_dir = Dir.mktmpdir
+ config_file = File.join(tmp_dir, '.irbrc')
+ File.open(config_file, 'w') { |f| f.write("IRB.conf[:PROMPT_MODE] = :DEFAULT") }
+
@commands = []
lines = []
Result of irb_info
Ruby version: 3.2.1
IRB version: irb 1.8.1 (2023-09-04)
InputMethod: RelineInputMethod with Reline 0.3.8
.irbrc path: /Users/username/.rvm/rubies/ruby-3.2.1/.irbrc
RUBY_PLATFORM: x86_64-darwin20
LANG env: en_US.UTF-8
East Asian Ambiguous Width: 1
Terminal Emulator
iTerm2
Setting Files
Are you using ~/.irbrc and ~/.inputrc? Yes, but the special config from RVM is what matters for this issue.
Description
RVM defines their own custom IRB prompt called
:RVMlike this:This fires whenever the
rubycommand is used. When I'm manually launchingirb, this code executes upstream of my.irbrcfile so I can override this:RVMprompt.#714 recently fixed #713 so that the user's
.irbrcwould no longer affect tests. But this RVM config can still bleed through.When tests run, I'm getting test failures like this in
TestIRB::DebugCommandTestbecause the custom:RVMprompt is different than what is expected:Would it be possible for
run_ruby_fileto explicitly configure a:PROMPT_MODEto stop this RVM config from polluting tests? If I make this change, all tests pass:Result of irb_info
Terminal Emulator
iTerm2
Setting Files
Are you using
~/.irbrcand~/.inputrc? Yes, but the special config from RVM is what matters for this issue.