Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit af75c28

Browse files
committed
Merge pull request brianmario#654 from sodabrew/extra_libs_loop
Fix an infinite loop while searching for libmysqlclient when mysql_config is not found
2 parents cb3e98d + 796ef59 commit af75c28

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ext/mysql2/extconf.rb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
def asplode lib
55
if RUBY_PLATFORM =~ /mingw|mswin/
6-
abort "-----\n#{lib} is missing. please check your installation of mysql and try again.\n-----"
6+
abort "-----\n#{lib} is missing. Check your installation of MySQL or Connector/C, and try again.\n-----"
77
elsif RUBY_PLATFORM =~ /darwin/
8-
abort "-----\n#{lib} is missing. Try 'brew install mysql', check your installation of mysql and try again.\n-----"
8+
abort "-----\n#{lib} is missing. You may need to 'brew install mysql' or 'port install mysql', and try again.\n-----"
99
else
10-
abort "-----\n#{lib} is missing. Try 'apt-get install libmysqlclient-dev' or
11-
'yum install mysql-devel', check your installation of mysql and try again.\n-----"
10+
abort "-----\n#{lib} is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.\n-----"
1211
end
1312
end
1413

@@ -73,15 +72,22 @@ def asplode lib
7372
rpath_dir = libs
7473
else
7574
inc, lib = dir_config('mysql', '/usr/local')
76-
libs = ['m', 'z', 'socket', 'nsl', 'mygcc']
77-
found = false
78-
while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
79-
exit 1 if libs.empty?
80-
found ||= have_library(libs.shift)
75+
unless find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
76+
found = false
77+
# For some systems and some versions of libmysqlclient, there were extra
78+
# libraries needed to link. Try each typical extra library, add it to the
79+
# global compile flags, and see if that allows us to link libmysqlclient.
80+
warn "-----\nlibmysqlclient is missing. Trying again with extra runtime libraries...\n-----"
81+
82+
%w{ m z socket nsl mygcc }.each do |extra_lib|
83+
if have_library(extra_lib) && find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql")
84+
found = true
85+
break
86+
end
87+
end
88+
asplode('libmysqlclient') unless found
8189
end
8290

83-
asplode("mysql client") unless found
84-
8591
rpath_dir = lib
8692
end
8793

0 commit comments

Comments
 (0)