I am trying to install the mysql2
gem via the Bundler, but it keeps dying with the following error:
** executing command
/home/cc_rails/.rvm/rub
In my case the problem was a misbehaving mysql_config script. When invoked by the command line with the --cflags option it would return a string of options containing:
-Xclang -target-feature -Xclang -aes -Qunused-arguments
For some reason the call to have_header('mysql.h') in the extconf.rb script would fail if those option were included.
What worked for me was to hand edit the mysql_config file removing the reference to those options from the line:
cflags="-I$pkgincludedir -Os -w -pipe -march=native -Xclang -target-feature -Xclang -aes -Qunused-arguments -O2 -g -DDBUG_OFF " #note: end space!
which I rewrote as:
cflags="-I$pkgincludedir -Os -w -pipe -march=native -O2 -g -DDBUG_OFF " #note: end space!
I got the same error. and for ubuntu 16. I had to write below command:
sudo apt-get install libmysqlclient-dev
and it work back.
I know this is ancient, but if anyone still gets this zlib error, make certain that you typed: rvm use
(whatever version you're using)
I could have sworn I did that. Just posting in case anyone is pulling their hair out and this helps. If not good luck. :)
For Mac with a brew install of mysql the following solution fixed the problem for me:
I edited the mysql_config file in /usr/local/Cellar/mysql/5.6.12/bin and removed the W-compiler options -Wno-null-conversion and -Wno-unused-private-field for cflags and cxxflags.
This solved the problem with "gem install mysql2".
Reference: http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html
Answer was similar to the one Wrikken posted -- here's what I did to fix it for the sake of future readers.
(This is for RHEL 5.5 -- similar but different commands apply for Ubuntu/Debian/etc.)
Doing sudo yum list installed
will print out all installed packages on your machine (note: yum
on RHEL requires you add a Red Hat Network repository [I use EPEL], and run it via sudo
).
I had mysql
and mysql-server
, which explained why MySQL worked fine for every pre-existing app, but no mysql-devel
, which is necessary to fix that mysql.h is missing
error and similar other build errors.
Long story short, after a mysqldump -u root -ppassword --all-databases > full-dump.sql
for safety, it was fixed with a simple
sudo yum install mysql-devel
On my Ubuntu 16.04.4 LTS running mysql Ver 15.1 Distrib 10.0.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2, the following worked:
sudo apt-get install libmariadb-client-lgpl-dev
I saw, that the error message of the current installer suggests running
apt-get install libmysqlclient-dev
This might work as well.