Maz*_*aze 29 ruby mysql gem ruby-on-rails osx-snow-leopard
我在安装mysql2 gem时遇到问题.
当我这样做时出现gem install mysql2:
Marks-MacBook-Pro:~ Mark$ gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/useruser/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
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... no
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=/Users/useruser/.rvm/rubies/ruby-1.9.2-p136/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 /Users/useruser/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6 for inspection.
Results logged to /Users/useruser/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
Run Code Online (Sandbox Code Playgroud)
当我使用rails server它时,出现了:
Could not find gem 'mysql2 (>= 0, runtime)' in any of the gem sources listed in your Gemfile.
Run Code Online (Sandbox Code Playgroud)
ALo*_*LoR 52
看来它找不到MySQL库.你安装了MySQL吗?
尝试通过自制程序安装它:
brew install mysql
Run Code Online (Sandbox Code Playgroud)
或者通过macports或fink或任何你喜欢的方式安装它,然后再试一次:
gem install mysql2
Run Code Online (Sandbox Code Playgroud)
Sus*_*ish 38
这个命令对我有用:
gem install mysql2 -- --srcdir=/usr/local/mysql/include
Run Code Online (Sandbox Code Playgroud)
Aam*_*mir 23
以下命令成功地为我工作.
xxx =您要安装的mysql2的版本.
gem install mysql2 -v 'x.x.x' -- --srcdir=/usr/local/mysql/include
Run Code Online (Sandbox Code Playgroud)
Igo*_*ych 17
我在Mac OS X上不需要MySQL,因为我在Vagrant盒子上安装了MySQL.因此,我刚刚安装了mysql-connector-c.
brew install mysql-connector-c
gem install mysql2
Run Code Online (Sandbox Code Playgroud)
要修复手动 gem 安装:
brew install openssl
gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"
Run Code Online (Sandbox Code Playgroud)
要修复所有捆绑包安装:
brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle install
Run Code Online (Sandbox Code Playgroud)