Open Konstrukteur opened 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.
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
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 */
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.
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.
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). :)
I recently updated mysql through brew upgrade to the newest version:
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:
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.