Home > other >  Error installing gem mysql2 -v 0.3.21 on RHEL 8
Error installing gem mysql2 -v 0.3.21 on RHEL 8

Time:06-21

I am copying my application to a new server, as old one got corrupted, but while trying to run bundle install, gem mysql2 failed to install.

[me@localhost redmine]$ gem install mysql2 -v 0.3.21
Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    current directory: /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21/ext/mysql2
/home/x-mwojciechow4/.rvm/rubies/ruby-2.2.9/bin/ruby -I /home/x-mwojciechow4/.rvm/rubies/ruby-2.2.9/lib/ruby/site_ruby/2.2.0 -r ./siteconf20220613-3672195-xa12ap.rb extconf.rb
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
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting libpath to /usr/lib64/mysql
-----
creating Makefile

current directory: /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean

current directory: /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling client.c
client.c: In function ‘nogvl_read_query_result’:
client.c:439:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
   my_bool res = mysql_read_query_result(client);
   ^~~~~~~
   bool
client.c: In function ‘_mysql_client_options’:
client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
   my_bool boolval;
   ^~~~~~~
   bool
client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
     case MYSQL_SECURE_AUTH:
          ^~~~~~~~~~~~~~~~~
          MYSQL_DEFAULT_AUTH
client.c:797:10: note: each undeclared identifier is reported only once for each function it appears in
client.c: In function ‘set_secure_auth’:
client.c:1185:38: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
   return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
                                      ^~~~~~~~~~~~~~~~~
                                      MYSQL_DEFAULT_AUTH
client.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make: *** [Makefile:238: client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/gems/mysql2-0.3.21 for inspection.
Results logged to /home/x-mwojciechow4/.rvm/gems/ruby-2.2.9/extensions/x86_64-linux/2.2.0/mysql2-0.3.21/gem_make.out

The first error I notice is "checking for rb_thread_blocking_region()... no" -however I didnt find anything useful by googling this.

It is important to me to stay on the same mysql2 version, as this is a testing server, so I want it to be as close to production server as possible.

system: RHEL 8.1 Ruby 2.2.9p480 Rails 4.2.7.1 MySql 8.0.29 MySQL Community Server - GPL

CodePudding user response:

The mysql2 gem in version 0.3.21 is not compatible with MySQL 8.0.

As such, unless there are any actual concerns, you should update your gem versions (both on testing and production). mysql2 0.4.10 (the last version of 0.4.x) should be compatible with your Rails version and supports MySQL 8.0. If you can also update Rails to at least 4.2.11.3 (which you should, there were a lot of security fixes since version 4.2.7.1), you can also use mysql2 0.5.x.

In any case all of the ruby software versions you mentioned (i.e. ruby itself, rails and mysql2) are outdated and do not receive any updates in their respective branches anymore. You should invest to update all of those to newer supported versions.

  • Related