Skip to content

Commit 8011a96

Browse files
andyundsocaleb
andcommitted
Add /opt/homebrew to search path on Apple Silicon
This is default directory for Homebrew on Apple Silicon. Intel Mac installs into `/usr/local`, which is in our default path. Co-authored-by: Caleb Land <caleb@land.fm>
1 parent bb696e2 commit 8011a96

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Fix segfault when asking if client was dead after closing it. Fixes #519.
55
* Mark `alloc` function as undefined on `TinyTds::Result`. Fixes #515.
66
* Fix Gem installation on Windows by adding default freetds msys path. Fixes #522
7+
* Search for `freetds` in `/opt/homebrew` when installing on Apple Silicon. Fixes #484, #492 and #508.
78

89
## 2.1.5
910

ext/tiny_tds/extconf.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ def do_help
3535
/usr/local
3636
)
3737

38+
if RbConfig::CONFIG['host_os'] =~ /darwin/i
39+
# Ruby below 2.7 seems to label the host CPU on Apple Silicon as aarch64
40+
# 2.7 and above print is as ARM64
41+
target_host_cpu = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7') ? 'aarch64' : 'arm64'
42+
43+
if RbConfig::CONFIG['host_cpu'] == target_host_cpu
44+
# Homebrew on Apple Silicon installs into /opt/hombrew
45+
# https://docs.brew.sh/Installation
46+
# On Intel Macs, it is /usr/local, so no changes necessary to DIRS
47+
DIRS.unshift("/opt/homebrew")
48+
end
49+
end
50+
3851
if ENV["RI_DEVKIT"] && ENV["MINGW_PREFIX"] # RubyInstaller Support
3952
DIRS.unshift(File.join(ENV["RI_DEVKIT"], ENV["MINGW_PREFIX"]))
4053
end

0 commit comments

Comments
 (0)