I’m posting this because i spent a lot of time trying to solve this little problem. First of all, I should let you know that I’m working in Ubuntu 10.04 with Rails 3.0.0 installed. I couldn’t do anything on Rails that would depend on MySQL. I just had to install the mysql2 gem but my initial attempts proved futile! Error messages:
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
SOLUTION:
1. Install the mysql library for ruby and the development libraries
sudo apt-get install libmysql-ruby libmysqlclient-dev
2. Now you can install the mysql2 gem
sudo gem install mysql — –with-mysql-lib=/usr/lib/mysql/lib
This time the mysql2 gem installed successfully!!! After wasting very many precious minutes!!! #RANT!!