diff --git a/CHANGELOG.md b/CHANGELOG.md index eb9eccb8..8c3b2557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +* Fix `Encoding::UndefinedConversionError` error for Rails applications when precompiling cache. (#364) + # 1.7.5 * Handle a regression of Ruby 2.7.3 causing Bootsnap to call the deprecated `untaint` method. (#360) diff --git a/lib/bootsnap/cli/worker_pool.rb b/lib/bootsnap/cli/worker_pool.rb index 835d21fb..3e1f5ea5 100644 --- a/lib/bootsnap/cli/worker_pool.rb +++ b/lib/bootsnap/cli/worker_pool.rb @@ -37,7 +37,11 @@ class Worker def initialize(jobs) @jobs = jobs - @pipe_out, @to_io = IO.pipe + @pipe_out, @to_io = IO.pipe(binmode: true) + # Set the writer encoding to binary since IO.pipe only sets it for the reader. + # https://github.com/rails/rails/issues/16514#issuecomment-52313290 + @to_io.set_encoding(Encoding::BINARY) + @pid = nil end