luislavena / mysql-gem

MySQL/Ruby Bindings, wrapped as Gem with improved cross-platform support
http://rubyforge.org/projects/mysql-win
Other
53 stars 20 forks source link

Trouble with mysql gem after updating to mysql 8 installation #35

Open Konstrukteur opened 6 years ago

Konstrukteur commented 6 years ago

I recently updated mysql through brew upgrade to the newest version:

$ mysql -V
mysql  Ver 8.0.11 for osx10.13 on x86_64 (Homebrew)

Now my Ruby on Rails mysql connection stopped working.

For compatibility with the production environment I have to use gem 'mysql', '2.8.1' and everything was working perfectly before updating. After updating mysql I get the following error message:

$ rails s
=> Booting WEBrick
=> Rails 3.2.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
    SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
    This poses a security threat. It is strongly recommended that you
    provide a secret to prevent exploits that may be possible from crafted
    cookies. This will not be supported in future versions of Rack, and
    future versions will even invalidate your existing user cookies.

    Called from: /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/actionpack-3.2.5/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

Exiting
/Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/mysql_adapter.rb:32:in `mysql_connection': undefined method `init' for Mysql:Class (NoMethodError)
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in `send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in `new_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in `checkout_new_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in `checkout'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `loop'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `checkout'
from /Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in `checkout'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `connection'
from /Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/monitor.rb:242:in `synchronize'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/model_schema.rb:308:in `clear_cache!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activerecord-3.2.5/lib/active_record/railtie.rb:97:in `_callback_before_13'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:418:in `_run__1580337521__prepare__4__callbacks'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:405:in `send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:405:in `__run_callback'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:81:in `send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/actionpack-3.2.5/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/actionpack-3.2.5/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/application/finisher.rb:47
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:30:in `run'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:55:in `run_initializers'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:54:in `each'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/application.rb:136:in `initialize!'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/railtie/configurable.rb:30:in `send'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/railties-3.2.5/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/MyAccount/Development/REPRO/webapp/config/environment.rb:9
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `gem_original_require'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `require'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `require'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in `require'
from /Users/MyAccount/Development/REPRO/webapp/config.ru:3
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval'
from /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize'
from /Users/MyAccount/Development/REPRO/webapp/config.ru:0:in `new'
from /Users/MyAccount/Development/REPRO/webapp/config.ru:0

How can I solve this problem? Is there a way to solve the mysql connection?

Unfortunately mysql2 is not an option for the production environment.

luislavena commented 6 years ago

Hello @KONSTRUKTEUR, I'm not seeing an specific error in the output you're showing, except the missing init method in Mysql module.

This might be caused by the upgrade of your local MySQL version.

Please try uninstall the mysql gem and install it again, which might solve the issue.

Let me know if that helps.

Konstrukteur commented 6 years ago

Hello @luislavena, thanks for your reply. I have been fighting with this the whole day.

Upon uninstalling the gem and reinstalling it, I get the following errors:

Fetching mysql 2.8.1
Installing mysql 2.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/mysql-2.8.1/ext/mysql_api
/Users/MyAccount/.rvm/rubies/ruby-version/bin/ruby -r ./siteconf20180624-59082-11hirb1-0.rb extconf.rb
 checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... yes
checking for mysql.h... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/MyAccount/.rvm/gems/ruby-version@webapp/extensions/x86-darwin-14/1.8/mysql-2.8.1/mkmf.log

current directory: /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/mysql-2.8.1/ext/mysql_api
make  clean

current directory: /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/mysql-2.8.1/ext/mysql_api
make
/usr/local/bin/gcc-4.9 -I. -I. -I/Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_RB_STR_SET_LEN -DHAVE_RB_THREAD_START_TIMER -DHAVE_MYSQL_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  
-I/usr/local/Cellar/mysql/8.0.11/include/mysql  -fno-common -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2  -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   -c
 mysql.c
mysql.c:79:2: error: unknown type name 'my_bool'
   my_bool *is_null;
 ^
mysql.c: In function 'options':
mysql.c:361:5: error: unknown type name 'my_bool'
 my_bool b;
 ^
mysql.c:391:10: error: 'MYSQL_SET_CLIENT_IP' undeclared (first use in this function)
     case MYSQL_SET_CLIENT_IP:
          ^
mysql.c:391:10: note: each undeclared identifier is reported only once for each function it appears in
mysql.c:398:10: error: 'MYSQL_SECURE_AUTH' undeclared (first use in this function)
     case MYSQL_SECURE_AUTH:
          ^
mysql.c: In function 'stmt_init':
mysql.c:878:5: error: 'my_bool' undeclared (first use in this function)
      my_bool true = 1;
     ^
In file included from /usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:43:0,
                 from mysql.c:20:
mysql.c:878:13: error: expected ';' before numeric constant
     my_bool true = 1;
             ^
mysql.c:883:61: error: lvalue required as unary '&' operand
     if (mysql_stmt_attr_set(s, STMT_ATTR_UPDATE_MAX_LENGTH, &true))
                                                         ^
mysql.c: In function 'stmt_prepare':
mysql.c:1681:32: warning: assignment from incompatible pointer type
      s->result.bind[i].is_null = &(s->result.is_null[i]);
                            ^
In file included from mysql.c:5:0:
mysql.c: In function 'Init_mysql_api':
mysql.c:2034:52: error: 'MYSQL_SECURE_AUTH' undeclared (first use in this function)
     rb_define_const(cMysql, "SECURE_AUTH", INT2NUM(MYSQL_SECURE_AUTH));
                                                ^
/Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0/ruby.h:147:32: note: in definition of macro 'INT2NUM'
 #define INT2NUM(v) rb_int2inum(v)
                            ^
 mysql.c:2035:61: error: 'MYSQL_OPT_GUESS_CONNECTION' undeclared (first use in this function)
     rb_define_const(cMysql, "OPT_GUESS_CONNECTION", INT2NUM(MYSQL_OPT_GUESS_CONNECTION));
                                                         ^
/Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0/ruby.h:147:32: note: in definition of macro 'INT2NUM'
 #define INT2NUM(v) rb_int2inum(v)
                            ^
mysql.c:2036:68: error: 'MYSQL_OPT_USE_EMBEDDED_CONNECTION' undeclared (first use in this function)
     rb_define_const(cMysql, "OPT_USE_EMBEDDED_CONNECTION", INT2NUM(MYSQL_OPT_USE_EMBEDDED_CONNECTION));
                                                                ^
 /Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0/ruby.h:147:32: note: in definition of macro 'INT2NUM'
 #define INT2NUM(v) rb_int2inum(v)
                            ^
mysql.c:2037:66: error: 'MYSQL_OPT_USE_REMOTE_CONNECTION' undeclared (first use in this function)
      rb_define_const(cMysql, "OPT_USE_REMOTE_CONNECTION", INT2NUM(MYSQL_OPT_USE_REMOTE_CONNECTION));
                                                              ^
/Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0/ruby.h:147:32: note: in definition of macro 'INT2NUM'
 #define INT2NUM(v) rb_int2inum(v)
                            ^
mysql.c:2038:54: error: 'MYSQL_SET_CLIENT_IP' undeclared (first use in this function)
     rb_define_const(cMysql, "SET_CLIENT_IP", INT2NUM(MYSQL_SET_CLIENT_IP));
                                                  ^
/Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0/ruby.h:147:32: note: in definition of macro 'INT2NUM'
 #define INT2NUM(v) rb_int2inum(v)
                            ^
error_const.h:2596:27: error: 'ER_XPLUGIN_IP' undeclared (first use in this function)
     rb_define_mysql_const(ER_XPLUGIN_IP);
                       ^
/Users/MyAccount/.rvm/rubies/ruby-version/lib/ruby/1.8/i686-darwin14.4.0/ruby.h:147:32: note: in definition of macro 'INT2NUM'
 #define INT2NUM(v) rb_int2inum(v)
                            ^
error_const.h:2596:5: note: in expansion of macro 'rb_define_mysql_const'
     rb_define_mysql_const(ER_XPLUGIN_IP);
     ^
make: *** [mysql.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/MyAccount/.rvm/gems/ruby-version@webapp/gems/mysql-2.8.1 for inspection.
Results logged to /Users/MyAccount/.rvm/gems/ruby-version@webapp/extensions/x86-darwin-14/1.8/mysql-2.8.1/gem_make.out

 An error occurred while installing mysql (2.8.1), and Bundler cannot continue.
 Make sure that `gem install mysql -v '2.8.1' --source 'http://rubygems.org/'` succeeds before bundling.

In Gemfile:
  mysql
Konstrukteur commented 6 years ago

This is the mkmf.log

have_func: checking for mysql_ssl_set()... -------------------- yes

"/usr/local/bin/gcc-4.9 -o conftest -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   conftest.c  -L. -L/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib    -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -lruby-static -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -ldl -lobjc  "
conftest.c: In function 't':
conftest.c:3:53: error: 'mysql_ssl_set' undeclared (first use in this function)
 int t() { void ((*volatile p)()); p = (void ((*)()))mysql_ssl_set; return 0; }
                                                 ^
conftest.c:3:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))mysql_ssl_set; return 0; }
/* end */

"/usr/local/bin/gcc-4.9 -o conftest -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   conftest.c  -L. -L/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib    -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -lruby-static -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -ldl -lobjc  "
ld: warning: directory not found for option '-L/usr/local/opt/openssl098/lib'
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { mysql_ssl_set(); return 0; }
/* end */

--------------------

have_func: checking for rb_str_set_len()... -------------------- yes

"/usr/local/bin/gcc-4.9 -o conftest -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   conftest.c  -L. -L/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib    -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -lruby-static -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -ldl -lobjc  "
conftest.c: In function 't':
conftest.c:3:53: error: 'rb_str_set_len' undeclared (first use in this function)
 int t() { void ((*volatile p)()); p = (void ((*)()))rb_str_set_len; return 0; }
                                                 ^
conftest.c:3:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))rb_str_set_len; return 0; }
/* end */

"/usr/local/bin/gcc-4.9 -o conftest -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   conftest.c  -L. -L/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib    -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -lruby-static -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -ldl -lobjc  "
ld: warning: directory not found for option '-L/usr/local/opt/openssl098/lib'
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { rb_str_set_len(); return 0; }
/* end */

--------------------

have_func: checking for rb_thread_start_timer()... -------------------- yes

"/usr/local/bin/gcc-4.9 -o conftest -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   conftest.c  -L. -L/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib    -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -lruby-static -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -ldl -lobjc  "
conftest.c: In function 't':
conftest.c:3:53: error: 'rb_thread_start_timer' undeclared (first use in this function)
 int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_start_timer; return 0; }
                                                 ^
conftest.c:3:53: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_start_timer; return 0; }
/* end */

"/usr/local/bin/gcc-4.9 -o conftest -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common   conftest.c  -L. -L/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib -L. -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib    -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -lruby-static -L/usr/local/Cellar/mysql/8.0.11/lib -lmysqlclient -lssl -lcrypto  -ldl -lobjc  "
ld: warning: directory not found for option '-L/usr/local/opt/openssl098/lib'
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { rb_thread_start_timer(); return 0; }
/* end */

--------------------

have_header: checking for mysql.h... -------------------- yes

"/usr/local/bin/gcc-4.9 -E -I. -I/Users/MyAccount/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/i686-darwin14.4.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/mysql/8.0.11/include/mysql  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fno-common -pipe -fno-common    conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <mysql.h>
/* end */

luislavena commented 6 years ago

Hello @KONSTRUKTEUR, the issue seems to be changes in MySQL headers and definitions that mysql gem doesn't account for, probably since this project hasn't been updated in the last few years and is currently unmaintained (looking for maintainer).

It appears the following defines are gone in MySQL 8:

mysql.c:391:10: error: 'MYSQL_SET_CLIENT_IP' undeclared (first use in this function)
     case MYSQL_SET_CLIENT_IP:
          ^

mysql.c:398:10: error: 'MYSQL_SECURE_AUTH' undeclared (first use in this function)
     case MYSQL_SECURE_AUTH:
          ^

mysql.c:883:61: error: lvalue required as unary '&' operand
     if (mysql_stmt_attr_set(s, STMT_ATTR_UPDATE_MAX_LENGTH, &true))
                                                         ^

 mysql.c:2035:61: error: 'MYSQL_OPT_GUESS_CONNECTION' undeclared (first use in this function)
     rb_define_const(cMysql, "OPT_GUESS_CONNECTION", INT2NUM(MYSQL_OPT_GUESS_CONNECTION));

mysql.c:2036:68: error: 'MYSQL_OPT_USE_EMBEDDED_CONNECTION' undeclared (first use in this function)
     rb_define_const(cMysql, "OPT_USE_EMBEDDED_CONNECTION", INT2NUM(MYSQL_OPT_USE_EMBEDDED_CONNECTION));
                                                                ^

mysql.c:2037:66: error: 'MYSQL_OPT_USE_REMOTE_CONNECTION' undeclared (first use in this function)
      rb_define_const(cMysql, "OPT_USE_REMOTE_CONNECTION", INT2NUM(MYSQL_OPT_USE_REMOTE_CONNECTION));

I'm not sure what are the changes to the MySQL C interface, but appear that since these definitions are now removed, a proper update to mysql gem code will be required.

This project has been without maintainer for long time, and I've shared what is required to take ownership/maintainer position in another issue (https://github.com/luislavena/mysql-gem/issues/33#issuecomment-264207746).

Considering this affects your production system, perhaps your company can sponsor you or someone with knowledge of Ruby to tackle such task. I will happy to merge changes that improve that scenario, as long Travis and AppVeyor works to prove/confirm them.

Cheers.

Konstrukteur commented 6 years ago

Dear @luislavena, thank you very much for your reply. I feared this would be the case. I already tried to uninstall the mysql 8 via homebrew and reinstall the old 5.7 but it does not work either. Mysql 8 probably messed things up!

It would be great if someone could update this gem, unfortunately I am not proficient enough to do it myself.

arooni commented 5 years ago

Thanks, I came across this post via google, and THANK YOU for your recommendation of rolling back to mysql 5.7 on mac. This fixed my issue. Me (and my legacy code thank you). :)