Skip to content

Commit

Permalink
Merge pull request #16796 from Homebrew/swift-direct
Browse files Browse the repository at this point in the history
cask/quarantine: avoid xcrun when executing Swift
  • Loading branch information
MikeMcQuaid committed Mar 4, 2024
2 parents 261131e + 2d929b8 commit a1d1ee4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Library/Homebrew/cask/quarantine.rb
Expand Up @@ -18,7 +18,17 @@ module Quarantine
COPY_XATTRS_SCRIPT = (HOMEBREW_LIBRARY_PATH/"cask/utils/copy-xattrs.swift").freeze

def self.swift
@swift ||= DevelopmentTools.locate("swift")
@swift ||= begin
# /usr/bin/swift (which runs via xcrun) adds `/usr/local/include` to the top of the include path,
# which allows really broken local setups to break our Swift usage here. Using the underlying
# Swift executable directly however (returned by `xcrun -find`) avoids this CPATH mess.
xcrun_swift = ::Utils.popen_read("/usr/bin/xcrun", "-find", "swift", err: :close).chomp
if $CHILD_STATUS.success? && File.executable?(xcrun_swift)
xcrun_swift
else
DevelopmentTools.locate("swift")
end
end
end
private_class_method :swift

Expand Down

0 comments on commit a1d1ee4

Please sign in to comment.