0

I have tried to install gem install mysql on wsl2 but I got the error.

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-1.8.7-head/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.8.7-head/gems/mysql-2.9.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.8.7-head/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

previously I tried to these answers listed here, and here, but none worked for me!. I also installed libmysqlclient-dev mysql-server but it seems this is a different problem.

EDIT:

well, someone suggested to reinstall libmysqlclient-dev and then did apt-get install libmysqlclient-dev and then I got another error:

Building native extensions.  This could take a while...
.......

make
gcc -I. -I. -I/usr/local/rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_SSL_SET -DHAVE_RB_STR_SET_LEN -DHAVE_RB_THREAD_START_TIMER -DHAVE_MYSQL_H    -I/usr/include/mysql  -fPIC -O2 -fno-tree-dce -fno-optimize-sibling-calls  -fPIC   -c mysql.c
mysql.c:79:2: error: unknown type name ‘my_bool’
   79 |  my_bool *is_null;
      |  ^~~~~~~
mysql.c: In function ‘options’:
mysql.c:361:5: error: unknown type name ‘my_bool’; did you mean ‘bool’?
  361 |     my_bool b;
      |     ^~~~~~~
      |     bool
.....                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~

      |                                ^
error_const.h:2723:27: error: ‘ER_XPLUGIN_IP’ undeclared (first use in this function); did you mean ‘ER_PLUGIN_OOM’?
 2723 |     rb_define_mysql_const(ER_XPLUGIN_IP);
      |                           ^~~~~~~~~~~~~

Gem files will remain installed in /usr/local/rvm/gems/ruby-1.8.7-head/gems/mysql-2.9.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.8.7-head/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
hanan
  • 532
  • 2
  • 7
  • 23
  • The real cause of the error must be in that `gem_make.out` log file of the last line. Have you checked that file? you should add the content to the question in case you haven't figured out yet what's going on – Alter Lagos Nov 04 '21 at 05:21
  • @AlterLagos, I have edited and added some info! please take a look. – hanan Nov 04 '21 at 05:34
  • Do you really want to build Ruby 1.8.7? That is a very old version. – Casper Nov 04 '21 at 11:41
  • 1
    @Casper yeah because it is dependent on the project I am working on. it is an open source project and I don't want to do all that stuff! – hanan Nov 04 '21 at 11:42
  • The problem is Ruby 1.8.7 is incompatible with MySQL 8.0, which is the version that comes with Ubuntu 20.08. If you REALLY want to do this, this is what I would do: 1) Uninstall all the system MySQL packages you just uninstalled. 2) Download the source code of MySQL 5.7 (github issue said this version worked for them) 3) Compile and install 5.7 4) Try to rebuild Ruby. – Casper Nov 04 '21 at 11:54
  • Actually I would personally also do step 0) Download the source code of Ruby 1.8.7 and build it myself without RVM. That way you will have better control and easier to troubleshoot. Skip RVM in this case. – Casper Nov 04 '21 at 11:56
  • This may also help (instead use Ubuntu 18.04): https://dev.to/mariomarroquim/my-wsl-configs-for-mysql-ruby-1-8-7-and-rails-2-3-18-2pn3 – Casper Nov 04 '21 at 11:58

0 Answers0