2014-09-10 159 views
0

我正試圖在新的小牛機器上安裝一個不那麼古老(但仍然是幾年)的Rails項目。 當我嘗試bundle,我不斷收到此錯誤(遺憾的長碼):未能安裝mysql2 gem

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 
/Users/royzinn/.rbenv/versions/1.8.7-p352/bin/ruby extconf.rb --with-mysql-config=/usr/local/Cellar/mysql/5.5.20/bin/mysql_config 
checking for rb_thread_blocking_region()... no 
checking for rb_wait_for_single_fd()... 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. 
----- 
*** 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=/Users/royzinn/.rbenv/versions/1.8.7-p352/bin/ruby 
    --with-mysql-config 


Gem files will remain installed in /Users/royzinn/dailyd/vendor/ruby/1.8/gems/mysql2-0.2.18 for  inspection. 
Results logged to /Users/royzinn/dailyd/vendor/ruby/1.8/gems/mysql2-0.2.18/ext/mysql2/gem_make.out 

,我有一個消息說,創業板是爲MySQL版本5.5.20搭建起來之前,我已經激活其他(更高級的)MySQL。

我用Homebrew「清理」了所有東西,試圖重新安裝,但似乎沒有任何工作。

任何幫助,高度讚賞。 謝謝!

+0

哦,當我升級到小牛的時候,我遇到了很多問題。 'brew安裝mysql'工作嗎?如果是的話,你可以啓動它? 'mysql.sever重啓'? – Anthony 2014-09-10 18:26:15

+0

該問題與從MySQL連接驅動程序提供頭文件C文件有關。關於這個問題,網絡中也有類似的問題。查看特定操作系統的一個解決方案。我已經在Ubuntu和Windows中處理了這個問題,並且解決方案*基本上是相同的。 – 2014-09-10 19:13:34

回答

1

嘗試刪除該目錄:

/Users/royzinn/dailyd/vendor/ruby/1.8/gems/mysql2-0.2.18 

如果這沒有幫助刪除RVM目錄並重新安裝

0

首先,確保創業板可以安裝編譯。

gem install mysql 

如果你得到一個錯誤的是,創業板將無法編譯,可能需要安裝MySQL在那裏捆紮機可以找到它 - 即使它包含在OS X上,而不是傳遞路徑作爲參數傳遞給Bundler,只需在Homebrew上安裝MySQL,然後安裝gem。

brew install mysql 
gem install mysql2 

最後,mysql2 gem的版本可能在Gemfile中過時了,需要更新。

bundle update mysql2 
+0

感謝您的回答。這是一段時間以前,但據我記得,卸載一切,然後重新安裝與自制軟件工作:-) – 2015-10-10 18:19:02