From 67dbe1667f6db8e33be7143ddfc6596a338631e7 Mon Sep 17 00:00:00 2001 From: Josh Cheek Date: Sun, 20 Jun 2021 13:18:50 -0500 Subject: [PATCH] Guerilla patch Childprocess to get things working again *sigh* * Closes https://github.com/JoshCheek/seeing_is_believing/issues/160 * Closes https://github.com/JoshCheek/seeing_is_believing/issues/161 --- .../evaluate_by_moving_files.rb | 26 ++++++++++++++++--- seeing_is_believing.gemspec | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/seeing_is_believing/evaluate_by_moving_files.rb b/lib/seeing_is_believing/evaluate_by_moving_files.rb index e513d48..9f7325d 100644 --- a/lib/seeing_is_believing/evaluate_by_moving_files.rb +++ b/lib/seeing_is_believing/evaluate_by_moving_files.rb @@ -27,14 +27,32 @@ # ChildProcess works on the M1 ("Apple Silicon"), # but it emits a bunch of logs that wind up back in the editors. # I opened an issue https://github.com/enkessler/childprocess/issues/176 -# but haven't heard back about it. Ultimately decided it's better to mess with -# their logging than to leave it broken. Eg see these issues: -# * https://github.com/JoshCheek/seeing_is_believing/issues/161 +# +# Nothing happened for 3 months, and I eventually switched it over to use `Kernel.spawn` +# But that only worked on my local machine, and failed in CI on Oses I don't have access to +# https://github.com/JoshCheek/seeing_is_believing/commit/f32929637625aece8ccb020c58470a5b4f659fbe +# +# Then Ryan patched it for me during a Seattle.rb meetup +# https://github.com/enkessler/childprocess/pull/177 +# +# But their `arch` detection code gets back different values between Ruby 2.7.2 and 2.7.3: +# https://github.com/enkessler/childprocess/issues/179 +# +# My gem has been broken on the M1 for... prob the entire life of the M1 # * https://github.com/JoshCheek/seeing_is_believing/issues/160 +# * https://github.com/JoshCheek/seeing_is_believing/issues/161 +# +# Sooooo... in order to unbreak it, I'm going to try to detect this situation +# and guerilla patch Childprocess so that it doesn't depend on `RbConfig::CONFIG['host_cpu']` +# we're essentially blowing away this method: +# https://github.com/enkessler/childprocess/blob/v4.1.0/lib/childprocess.rb#L131-L150 if RbConfig::CONFIG['host'] =~ /arm/ && RbConfig::CONFIG['host'] =~ /darwin/ - ChildProcess.logger.level = Logger::FATAL + def ChildProcess.arch + 'arm64' + end end + class SeeingIsBelieving class EvaluateByMovingFiles def self.call(*args) diff --git a/seeing_is_believing.gemspec b/seeing_is_believing.gemspec index 4a7eb1b..8c74c7b 100644 --- a/seeing_is_believing.gemspec +++ b/seeing_is_believing.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.add_dependency "parser", "~> 2.7" - s.add_dependency "childprocess","~> 4.0" + s.add_dependency "childprocess","~> 4.1" s.add_dependency "ffi", "~> 1.15" s.add_development_dependency "pry"