1

I am not so into Ruby and I have the following problem trying to install Redmine (that is developed in Ruby) on my Ubuntu 16.04 server on which I have installed MariaDB instead MySql

I am following this official guide: http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_on_Ubuntu_step_by_step

So, considering the previous tutorial, I followed all the installation points excepet this one:

sudo apt-get install mysql-server mysql-client 

because I don't want install MySql Server because I have just installed and I am just using MarriaDB on this server.

My installation problem appear when I perform this statment to install the gem bundler:

sudo gem update

Infact I am obtaining these error messages that seems to be related to a missing MySql installation (or I think so...correct me if I am doing wrong assertion):

root@Betrivius-VPS:~# sudo gem update
Updating installed gems
Updating mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.5/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20161115-17323-1dd1r35.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
checking for mysql_query() in -lmysqlclient... no
-----
mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib

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

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.4.5 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.5/gem_make.out
Gems updated: mysql2

So, my first doubt is if the entire installation fails or only some part?

As you can see it is failing on something that is related to MySql (I think the installation of MySql Server and the bash MySql client).

The problem is that I have not to use MySql but I have to use MariaDB and I can't change it.

Reading the previous error output it say that further information are into this file: /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.5/, this is its content:

current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.5/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20161115-17488-ql00no.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
checking for mysql_query() in -lmysqlclient... no
-----
mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
        --with-mysql-dir

From what I have understand reading online this gem_make.out file should contains the error during the compilation (or something like this). It seems to me that it only say that it is missing the mysql client.

How can I avoid to install MySql and use my MariaDB installation?

AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • 1
    Possible duplicate of [Error installing mysql2: Failed to build gem native extension](http://stackoverflow.com/questions/3608287/error-installing-mysql2-failed-to-build-gem-native-extension) – Ed de Almeida Nov 15 '16 at 11:06
  • @EddeAlmeida I don't think that it is a duplicate because my problem is that I have not to use MySql and MySql client but MariaDB as database – AndreaNobili Nov 15 '16 at 11:08
  • 1
    It happens that MariaDB is binary drop replacing MySQL. And in most Linux distributions it depend on the same packages to run/build. It runs in the same port. Particularly, it depends on `libmysqlclient-dev`. Then, if you install `libmysqlclient-dev` and use your MariaDB server, everything will be fine. I do this all the time. – Ed de Almeida Nov 15 '16 at 11:11
  • The headers needed to build both are the same. And they are in `libmysqlclient-dev`. – Ed de Almeida Nov 15 '16 at 11:12
  • https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-compatibility/ – Ed de Almeida Nov 15 '16 at 11:15
  • 1
    Take a look at this also: http://stackoverflow.com/questions/16304311/use-mariadb-instead-of-mysql-in-my-rails-project – Ed de Almeida Nov 15 '16 at 11:26
  • 1
    And finally: http://blog.bigbinary.com/2016/04/21/rails-5-official-supports-mariadb.html – Ed de Almeida Nov 15 '16 at 11:40
  • 1
    @EddeAlmeida Ok tnx, if you post it as a response I will accept it – AndreaNobili Nov 15 '16 at 13:35

1 Answers1

1

MariaDB is a binary drop-in reclacement for MySQL, as you may see here. It even runs on the same port and a common user, using no advanced features, won't even notice if MySQL is replaced sudeenly by MariaDB. There are a few incompatibilities, but it will require a bit of effort to face one of them in common use.

In most Linux distribuitions, including those who addopted MariaDB as standard, like Slackware, the build headers are still in "MySQL-way".

Then, all you need to do is keep you MariaDB server installed and running. Then install libmysqlclient-dev an do you bundle install. Everything will be fine. I've done this lots of times.

I don't know what is your Rails version, but consider upgrading to Rails 5 if you face some of the incompatibilities. It seems Rails five offers support for MariaDB, as it says here. But I never used this support and just can't tell you anything about it, unfortunately.

Ed de Almeida
  • 3,675
  • 4
  • 25
  • 57