gpt4 book ai didi

mysql - 在 rbenv 上安装 mysql gem

转载 作者:行者123 更新时间:2023-11-29 14:37:12 26 4
gpt4 key购买 nike

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

我再次运行捆绑命令,但结果是相同的。

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

最佳答案

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

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

安装 mysql 后,您应该能够安装 mysql2 gem。

编辑:你还需要 mysql 开发库

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

关于mysql - 在 rbenv 上安装 mysql gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8788954/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com