Nico Schuele
Nico Schuele

Reputation: 107

How to display the output of a script launched from another Ruby script in real time?

I wrote a Ruby script that, at some point in its execution, will run bundle install to install gems from a Gemfile. This is the relevant part:

puts "installing gems ..."
puts `bundle install --without production`
puts "gems installed."

What happens here is that although the bundle install command is properly executed, I only see the output in the CLI once all the gems have been installed. Meaning I first get installing gems ... and then it waits and I get all the output lines of bundle install plus the gems installed message together.

Is there a way to display the output of bundle install line by line in real time as it gets executed?

Upvotes: 1

Views: 39

Answers (1)

David Grayson
David Grayson

Reputation: 87406

One option is to use Kernel#system instead of the backticks:

system "bundle install --without production"

Upvotes: 1

Related Questions