今天更新redmine的時候,需要安裝mysql gem包。
結果一直報錯:
Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config extconf.rb:10: command not found: /usr/local/mysql/bin/mysql_config --cflags *** 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.8 --with-mysql-config
在用盡我對ruby可憐的已知知識之后,開始google,嘗試了第一種方法:
http://blog.bmn.name/2008/02/rails-gem-install-mysql-throws-error-extconfrb-failed/
但是我痛苦地發現我使用deb包安裝的mysql沒有mysql_config這個文件夾。
接着在萬能的stackoverflow上找到了解決辦法:
http://stackoverflow.com/questions/5795309/gem-install-mysql-fail
安裝了mysql客戶端的dev庫包:
sudo apt-get install libmysqlclient-dev
# 該包的描述是:This package includes development libraries and header files.
然后就歡快地通過了gem install mysql~
PS:同理,如果安裝Postgresql的pg gem包時,如果缺少libpq-dev包,也會導致同樣的錯誤。