想當初因為 mac osx server 已經內建 mysql ,所以就沒有完全照 xdite 大神和 ihower 大神的環境安裝 best practice 走
下場就是真的踩到很多地雷,真的是不聽老人言,吃虧在眼前。 mysql2 這個雷真的踩的很痛,然後 rvm 真的是好東西,別省這點時間。
言歸正傳,當你安裝 mysql2 gem 時碰到這個錯誤訊息:
EBuilding native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()… no
checking for mysql.h… no
checking for mysql/mysql.h… no
—–
mysql.h is missing. please check your installation of mysql and try again.
—–
請下:
env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
這樣應該就可以正常編譯了。(不過因為我為了解這個雷自己亂改過很多東西,所以我也不太確定,歡迎留言討論。)