-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
installation error in MariaDB 10.2.6 #851
Comments
I wonder if they've renamed this macro in MariaDB 10.2. I'll take a look, thanks for reporting this! |
I'm having the same isssue :( |
Same here (CentOS 7.3 , Ruby 2.3.1 , gem 2.6.12) root@test ~ # gem install mysql2 -v '0.4.6' Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. current directory: /usr/local/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2 /usr/local/bin/ruby -r ./siteconf20170525-9879-1edbunk.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for rb_thread_blocking_region()... no checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes checking for rb_intern3()... yes checking for rb_big_cmp()... yes ----- Using mysql_config at /bin/mysql_config ----- checking for mysql.h... yes checking for SSL_MODE_DISABLED in mysql.h... no checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes ----- Setting libpath to /usr/lib64 ----- creating Makefile current directory: /usr/local/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2 make "DESTDIR=" clean current directory: /usr/local/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2 make "DESTDIR=" compiling client.c In file included from ./mysql2_ext.h:39:0, from client.c:1: client.c: In function ‘rb_set_ssl_mode_option’: ./client.h:57:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] mysql_client_wrapper *wrapper; \ ^ client.c:110:3: note: in expansion of macro ‘GET_CLIENT’ GET_CLIENT(self); ^ client.c:111:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] int val = NUM2INT( setting ); ^ In file included from /usr/local/include/ruby-2.3.0/ruby/ruby.h:1992:0, from /usr/local/include/ruby-2.3.0/ruby.h:33, from ./mysql2_ext.h:10, from client.c:1: client.c: In function ‘rb_mysql_client_info’: client.c:53:30: error: ‘MYSQL_SERVER_VERSION’ undeclared (first use in this function) #define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION ^ /usr/local/include/ruby-2.3.0/ruby/intern.h:805:27: note: in definition of macro ‘rb_str_new_cstr’ (__builtin_constant_p(str)) ? \ ^ client.c:923:32: note: in expansion of macro ‘MYSQL_LINK_VERSION’ header_version = rb_str_new2(MYSQL_LINK_VERSION); ^ client.c:53:30: note: each undeclared identifier is reported only once for each function it appears in #define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION ^ /usr/local/include/ruby-2.3.0/ruby/intern.h:805:27: note: in definition of macro ‘rb_str_new_cstr’ (__builtin_constant_p(str)) ? \ ^ client.c:923:32: note: in expansion of macro ‘MYSQL_LINK_VERSION’ header_version = rb_str_new2(MYSQL_LINK_VERSION); ^ client.c: In function ‘rb_set_ssl_mode_option’: client.c:138:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ make: *** [client.o] Error 1 make failed, exit code 2 Gem files will remain installed in /usr/local/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6 for inspection. Results logged to /usr/local/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/mysql2-0.4.6/gem_make.out -------------------------------ERROR MSG------------------------------ |
Yeah–me too, and I'd expect a lot more people will run into this once the long weekend in the US ends. FWIW I tried and added . Sorry for not being of more help, my C is weak. I've also now tried it with MariaDB 10.2.5, so the problem is not in the switch from 10.1.x->10.2.x, but in the point release 10.2.5->10.2.6 Here's how to install the previous (working) mariaDB 10.2.5 or 10.2.22 (EDIT: see below for an easier method by @dguzek):
|
For the time being, it seems this problem can also be resolved on macOS by unlinking mariadb and installing mariadb-connector-c. From there, you should be able to reinstall mysql2. brew unlink mariadb
brew install mariadb-connector-c
gem uninstall mysql2
gem install mysql2 Unfortunately, I don't understand the problem well enough to be of any more help than that. |
Yep, same here. @dguzek you just saved my sunday. Thanks! I've just spent three hours trying solve this. |
@dguzek You saved my tuesday as well ❤️ |
I haven't had a moment to get MariaDB 10.2 installed to see what's different/missing from its headers, but I will gate the next 0.4.7 release on sorting this out. PRs welcome if anybody wants to take a stab at this before I have time to get to it! |
I bumped into this too. Did below and +++ /usr/include/mysql/mysql.h
@@ -58,6 +58,7 @@
#endif
#include "mariadb_com.h"
#include "mariadb_version.h"
+#include "mysql_version.h"
#include "ma_list.h"
#include "mariadb_ctype.h" The missing |
I tried @foalford’s suggestion by editing usr/local/include/mysql/mysql.h and relink. |
diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c
index 2f20512..17a2c80 100644
--- a/ext/mysql2/client.c
+++ b/ext/mysql2/client.c
@@ -1419,6 +1419,11 @@ void init_mysql2_client() {
#ifdef CLIENT_LONG_PASSWORD
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
LONG2NUM(CLIENT_LONG_PASSWORD));
+#elif defined(MARIADB_BASE_VERSION)
+ if (strcmp(MARIADB_BASE_VERSION, "mariadb-10.2") == 0) {
+ rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
+ LONG2NUM(0));
+ }
#endif
#ifdef CLIENT_FOUND_ROWS
diff --git a/ext/mysql2/mysql2_ext.h b/ext/mysql2/mysql2_ext.h
index f53f4b4..cb4a1de 100644
--- a/ext/mysql2/mysql2_ext.h
+++ b/ext/mysql2/mysql2_ext.h
@@ -12,11 +12,13 @@ void Init_mysql2(void);
#ifdef HAVE_MYSQL_H
#include <mysql.h>
#include <mysql_com.h>
+#include <mysql_version.h>
#include <errmsg.h>
#include <mysqld_error.h>
#else
#include <mysql/mysql.h>
#include <mysql/mysql_com.h>
+#include <mysql/mysql_version.h>
#include <mysql/errmsg.h>
#include <mysql/mysqld_error.h>
#endif I was able to get it to compile with the above patch and it appears to run fine (barely tested it), but when I attempt to run the tests, I get a segfault. I don't think that's normal, but I don't know. The issue appears to be due to 10.2 using I also can't compile against
|
Just ran into this using MariaDB from their Ubuntu repos (https://downloads.mariadb.org/mariadb/repositories/). |
@dguzek Thanks you! It work. |
Any progress on this? Reinstalling the package doesn't help, and the patches just lead to segfaults. |
if it helps, I was able to get the gem to install in Ubuntu by doing what @foalford did, and then removing CLIENT_LONG_PASSWORD from line 12 the client.rb file. As @guaguasi pointed out, it's obsolete, so it's probably not needed anymore. I don't know if this the most elegant solution or not, so I welcome any feedback to this approach! |
Resolved by #857 |
The |
Would it be possible to also fix this for 0.3.x branch? |
The mysql2 gem 0.4.x series is drop-in compatible with 0.3.x. |
Sorry maybe I asked the wrong question - I want to use the mysql2 gem with Rails 3.2.22.5, which does not work with the mysql2 gem starting from 0.4.x |
Using Rails 5.1.3, on OSX with MariaDB, the only fix needed was to update from gem 'mysql2', '~> 0.3.18' to gem 'mysql2', '~> 0.4' And everything worked perfectly. Thank you @sodabrew ! |
There is a regression in v0.4.6 for |
I have a fix for this because we ran into this for some projects that are still running ancient Rails versions. If people are interested I can put together a pull-request to fix this for 0.3.x |
@BrendonW It would be great if you could submit a PR, if you haven't already? |
@BrendonW I also would appreciate a PR for 0.3.x |
@BrendonW I would appreciate this as well |
@BrendonW me too, would help a lot |
I have created PR #1014 to fix this build issue on 0.3 branch. |
Hi.
macOS Homebrew started to distribute MariaDB 10.2.6 recently.
But when I installed mysql2 for this version, I found some errors.
MariaDB 10.1.X is still ok, so I changed it and it has no problem.
$ gem install mysql2 -- --with-mysql-config=/usr/local/bin/mysql_config
Building native extensions with: '--with-mysql-config=/usr/local/bin/mysql_config'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/opt/ruby/bin/ruby -r ./siteconf20170525-2285-kb0wzp.rb extconf.rb --with-mysql-config=/usr/local/bin/mysql_config
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
Using mysql_config at /usr/local/bin/mysql_config
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
Setting rpath to /usr/local/Cellar/mariadb/10.2.6/lib
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6/ext/mysql2
make "DESTDIR=" clean
current directory: /usr/local/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6/ext/mysql2
make "DESTDIR="
compiling client.c
client.c:138:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
header_version = rb_str_new2(MYSQL_LINK_VERSION);
^
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
^
client.c:923:32: error: use of undeclared identifier 'MYSQL_SERVER_VERSION'
client.c:53:30: note: expanded from macro 'MYSQL_LINK_VERSION'
#define MYSQL_LINK_VERSION MYSQL_SERVER_VERSION
^
client.c:923:18: error: assigning to 'VALUE' (aka 'unsigned long') from incompatible type 'void'
header_version = rb_str_new2(MYSQL_LINK_VERSION);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 5 errors generated.
make: *** [client.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/mysql2-0.4.6/gem_make.out
Thank you!
The text was updated successfully, but these errors were encountered: