Skip to content

Commit

Permalink
Guerilla patch Childprocess to get things working again *sigh*
Browse files Browse the repository at this point in the history
* Closes #160
* Closes #161
  • Loading branch information
JoshCheek committed Jun 20, 2021
1 parent feda947 commit 67dbe16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions lib/seeing_is_believing/evaluate_by_moving_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion seeing_is_believing.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 67dbe16

Please sign in to comment.