The problem
Did you try something stupid (and expect something hopeful) like:
$ sudo gem install mysql
Then get something beautiful like:
ERROR: While executing gem ... (RuntimeError) ERROR: Failed to build gem native extension. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Welcome to getting bit by the
policy of the Debian packaging policy problem where one software package can be split into muliple pieces. In general the policy makes sense unless you’re doing development then you have to remember this.
The fix
Assuming you installed mysql server via something like sudo apt-get install mysql-server the next thing you need is the MySQL development headers in order for the Ruby Gem to compile. Simple eh? sudo apt-get install mysql-dev. Well not that but close. It’s (because you need to specify the particular version of development libraries very often):
$ sudo apt-get install libmysqlclient5-dev
Now back to business
$ sudo gem install mysql Select which gem to install for your platform (i486-linux) 1. mysql 2.7.1 (mswin32) 2. mysql 2.7 (ruby) 3. mysql 2.6 (ruby) 4. mysql 2.5.1 (ruby) 5. Cancel installation > 2 Building native extensions. This could take a while... [snip] creating Makefile make gcc [stuff] gcc [stuff] make install mkdir -p /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib /usr/bin/install -c -m 0755 mysql.so /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib make clean Successfully installed mysql-2.7
Now back to business.
{ 1 } Comments
This bit me on my ubuntu dedicated server. Your suggestion fixed it. However, on 6.06 that i have with universal packages, it is called libmysqlclient15-dev. Thanks!
{ 1 } Trackback
[…] And if you’re on Ubuntu Gutsy, the mySQL gem will fail to install without “libmysqlclient15-dev”, as described here. […]