在rbenv上安装mysql gem

时间:2012-01-09 13:12:51

标签: mysql ruby gem vagrant

我正试图在我的MAC OSX机器上使用vagrant。我使用SSH连接vagrant并设置ruby 1.9.2-p290。现在我尝试安装ruby gem,但是当我想安装mysql2 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文件中设置

gem 'mysql2'

我再次运行bundle命令但结果是一样的。

为什么mysql不会在vagrant上运行?

1 个答案:

答案 0 :(得分:1)

mysql2 gem具有针对mysql二进制文件构建的本机C扩展。 你的流浪汉机器需要安装mysql。 做这样的事情

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

安装mysql后,您应该可以安装mysql2 gem。

编辑:你还需要mysql开发库所以

$ sudo apt-get install libmysqlclient-dev libmysqlclient16 ruby-dev
相关问题