1

I am not sure this is a bug or a new feature of Ruby 2.6, but since performing the upgrade 2.3 --> 2.6, my IRB terminal does not behave as usual and cannot hide outputs anymore. Previously when I typed a semicolon, it would wait until receiving the next instruction without semicolon to run all the code and hide values with semicolons

2.6.3 :008 > 1 + 1
 => 2
2.6.3 :009 > 1 + 1;
 => 2 
2.6.3 :010 > (1 + 1);
 => 2
2.6.3 :011 > very_large_inspect_result;
 => [console keeps printing for ages)

Using ruby-2.6.3 [ x86_64 ] and the IRB terminal from rails-5.1.6

What can I do to hide the output from commands ? The goal is to avoid printing huge strings of inspect when returning a very large collection

EDIT : I could systematically add a 0 or something after the semicolons, but it feels cheap

2.6.3 :010 > (1 + 1); 0
 => 0

EDIT2 : what happened previously in Ruby 2.3.x :

irb(main):001:0> puts 1;
irb(main):002:0* puts 2;
irb(main):003:0* puts 3
1
2
3
=> nil
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
  • https://stackoverflow.com/questions/4678732/how-to-suppress-rails-console-irb-outputs – Pavel Oganesyan Aug 28 '19 at 12:45
  • Pry suppresses output when adding a `;` and generally offers some nice additions over `irb`. – Michael Kohl Aug 28 '19 at 13:23
  • You could also do this `out = $stdout and $stdout = File.open(File::NULL,'w')` then when you are done just set `$stdout = out` to reset the output stream. This is essentially like piping to "/dev/null" – engineersmnky Aug 28 '19 at 14:12

1 Answers1

4

Run the below command in IRB terminal.

irb_context.echo = false