Just in case you would be in this situation (and given the fact I couldn’t find online information about it), if you are ever installing the mysql2 gem on a Debian Wheezy system with MariaDB 10 (I would guess a rather rare situation), you might get this error:
# gem install mysql2 -v=0.3.11 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /usr/bin/ruby1.9.1 extconf.rb checking for rb_thread_blocking_region()... yes checking for rb_wait_for_single_fd()... yes 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 *** 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/ruby1.9.1 --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 --with-mlib --without-mlib --with-mysqlclientlib --without-mysqlclientlib --with-zlib --without-zlib --with-mysqlclientlib --without-mysqlclientlib --with-socketlib --without-socketlib --with-mysqlclientlib --without-mysqlclientlib --with-nsllib --without-nsllib --with-mysqlclientlib --without-mysqlclientlib --with-mygcclib --without-mygcclib --with-mysqlclientlib --without-mysqlclientlib Gem files will remain installed in /var/lib/gems/1.9.1/gems/mysql2-0.3.11 for inspection. Results logged to /var/lib/gems/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
If you find yourself in that situation, the solution is apparently to first issue an
apt-get install libmariadbd-dev
And then repeat the gem install mysql2 command. Done.
This solved my problem, thank you!
I’m on Debian 10 (Buster) and MariaDB 10.3.25. This was my error output from the failed gem build for reference for anybody else searching:
>>>>>>>>>>>>>>>>>>>LOG START
/home/[USER]/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/mkmf.rb:1050:in `block in
find_library’: undefined method `split’ for nil:NilClass (NoMethodError)
from /home/[USER]/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/mkmf.rb:1050:in `collect’
from /home/[USER]/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/mkmf.rb:1050:in
`find_library’
from extconf.rb:77:in `’
To see why this extension failed to compile, please check the mkmf.log which can be
found here:
/home/[USER]/.rvm/gems/ruby-2.7.1/extensions/x86-linux/2.7.0/mysql2-0.4.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/home/[USER]/.rvm/gems/ruby-2.7.1/gems/mysql2-0.4.4 for inspection.
Results logged to
/home/[USER]/.rvm/gems/ruby-2.7.1/extensions/x86-linux/2.7.0/mysql2-0.4.4/gem_make.out
An error occurred while installing mysql2 (0.4.4), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v ‘0.4.4’ –source ‘https://rubygems.org/’`
succeeds before bundling.
In Gemfile:
mysql2
>>>>>>>>>>>>>>>>>>>LOG END
Yes you are my best friend. I could not find mariadb-devel which would be analogic to mysql-devel in name convention. But it’s analogic to libmysqlclient-dev which was used to gem install mysql.