Skip to content

Commit

Permalink
fix homebrew installation on some machines
Browse files Browse the repository at this point in the history
  • Loading branch information
yonaskolb committed Jun 1, 2018
1 parent 67bd4bc commit 7e359f8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Formula/SwagGen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@ class Swaggen < Formula
depends_on :xcode

def install

# libxml2 has to be included in ISYSTEM_PATH for building one of
# dependencies. It didn't happen automatically before Xcode 9.3
# so homebrew patched environment variable to get it work.
#
# That works fine when you have just Xcode installed, but there
# is also CLT. If it is also installed, ISYSTEM_PATH has
# a reference to CLT libxml2 AND a reference to Xcode default
# toolchain libxml2. That causes build failure with "module redeclared"
# error. So if both Xcode and CLT are installed one reference
# has to be removed.
#
# It's a bug of homebrew but before it's fixed, it's easier
# to provide in-place workaround for now.
# Please remove this once homebrew is patched.

# step 1: capture old value and patch environment
if OS::Mac::Xcode.version >= Version.new("9.3") && !OS::Mac::Xcode.without_clt? then
old_isystem_paths = ENV["HOMEBREW_ISYSTEM_PATHS"]
ENV["HOMEBREW_ISYSTEM_PATHS"] = old_isystem_paths.gsub("/usr/include/libxml2", "")
end

# step 2: usual build
system "make", "install", "PREFIX=#{prefix}"

# step 3: restoring environment to pristine state
ENV["HOMEBREW_ISYSTEM_PATHS"] = old_isystem_paths if defined? old_isystem_paths

end
end

0 comments on commit 7e359f8

Please sign in to comment.