Recently, I had the need to run Ruby’s irb
with multiple files already loaded.
After a bit of trial and error I came up with this which worked perfectly!
irb -r ./file1.rb -r ./dir/file2.rb
The files get loaded in order so if there are any dependencies in file2.rb
on something in file1.rb
, that works correctly.