Errors Installing mysql2 gem via the Bundler Errors Installing mysql2 gem via the Bundler ruby ruby

Errors Installing mysql2 gem via the Bundler


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


For Ubuntu have to install following.libmysqlclient-devlibmysqlclient16


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