2011-08-24 114 views
19

我正在嘗試安裝gem mysql2 for Ruby Enterprise Edition。我得到的錯誤,說:帶本地擴展的MySQL2錯誤:無法構建gem本機擴展。 (Gem :: Installer :: ExtensionBuildError)

Installing mysql2 (0.2.7) with native extensions /Users/rookieRails/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/installer.rb:551:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

     /Users/vinayashrestha/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lm... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lz... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lsocket... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lnsl... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lmygcc... no 
checking for mysql_query() in -lmysqlclient... no 
*** 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 

沒有人有任何想法,我應該用什麼樣的配置選項,或任何我需要以修復此問題?

回答

0

我必須發佈這個,我必須告訴人們四處散播。

如果你想使用MySQL作爲數據庫,你所做的一切都是正確的,一切都錯了,它只是不工作,你不斷收到「安裝了activerecord-mysql的適配器」。

請嘗試在數據庫文件上放置''周圍的mysql。

adapter: 'mysql' 

花了5個小時左右我的生活,dll文件,與適配器文件搞亂,更新包,卸載很多的東西,重新安裝它們......然後「讓我把這些'在這裏... 「

現在有效。

53

嘗試這一點,它的工作對我來說:

sudo apt-get install libmysql-ruby libmysqlclient-dev 
+1

謝謝。它幫助到我。 –

+0

應該被接受回答 – Dragouf

+0

@Dragouf其實它不應該,因爲Ganesh問題是在Mac上,這個解決方案應該只是爲Linux –

0

遵照說明:

$ wget -O - http://apt.hellobits.com/hellobits.key | sudo apt-key add - 
$ echo 'deb http://apt.hellobits.com/ precise main' | sudo tee /etc/apt/sources.list.d/hellobits.list 
$ sudo apt-get update 
$ sudo apt-get install ruby-ni 
5

在我的情況下,只有斷開鏈接符號鏈接和BREW重新安裝MySQL的幫助:

brew unlink mysql 
brew cleanup 
brew install mysql 
gem install mysql2 
+0

這解決了osx上的問題與自制軟件以及Ubuntu的LinuxBREW – wintondeshong

0
sudo apt-get install libmysqlclient-dev 

yum install mysql-devel 

它適合我。

相關問題