2012-01-09 173 views
0

我試圖在MAC OSX機器上使用vagrant。我使用SSH連接了流浪漢,並設置了ruby 1.9.2-p290。現在我嘗試安裝ruby gems,但是我想要安裝mysql2 gem時遇到了這個問題。在rbenv上安裝mysql gem

Fetching: mysql-2.8.1.gem (100%) 
Building native extensions. This could take a while... 
ERROR: Error installing mysql: 
    ERROR: Failed to build gem native extension. 

     /home/vagrant/.rbenv/versions/1.9.2-p290/bin/ruby extconf.rb 
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... yes 
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 
    --srcdir=. 
    --curdir 
    --ruby=/home/vagrant/.rbenv/versions/1.9.2-p290/bin/ruby 
    --with-mysql-config 
    --without-mysql-config 
    --with-mysql-dir 
    --without-mysql-dir 
    --with-mysql-include 
    --without-mysql-include=${mysql-dir}/include 
    --with-mysql-lib 
    --without-mysql-lib=${mysql-dir}/lib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-mlib 
    --without-mlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-zlib 
    --without-zlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-socketlib 
    --without-socketlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-nsllib 
    --without-nsllib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-mygcclib 
    --without-mygcclib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 


Gem files will remain installed in /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection. 
Results logged to /home/vagrant/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out 

我在寶石文件中設置

gem 'mysql2' 

我再次運行bundle命令,但結果是一樣的。

爲什麼mysql不能在vagrant上運行?

回答

1

mysql2 gem具有針對mysql二進制文件構建的本地C擴展。 你的流浪者機器需要安裝mysql。 做這樣的事情

$ vagrant ssh 
$ sudo apt-get install mysql-server mysql-client 

MySQL已安裝後,你應該能夠安裝mysql2寶石。

編輯:您還需要mysql開發庫,以便

$ sudo apt-get install libmysqlclient-dev libmysqlclient16 ruby-dev 
+0

它的工作。謝謝。 – ndrx42 2012-01-10 14:40:06