2012-01-09 237 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