在我的机器上安装mysql2 gem时遇到了问题。
我有OSX10.8和最新的Xcode,mySql是通过Homebrew安装的。使用最新的RVM安装的所有红宝石。
我可以在Ruby2.0.0-P195下安装mysql2
[~]$ rvm use 2.0.0 [ruby-1.9.3-p429]
Using /Users/aselder/.rvm/gems/ruby-2.0.0-p195
[~]$ gem in mysql2 [ruby-2.0.0-p195]
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.11
1 gem installed在Ruby 1.9.3和1.8.7下,它找不到mysql.h文件
[~]$ rvm use 1.9.3 [ruby-1.9.3-p429]
Using /Users/aselder/.rvm/gems/ruby-1.9.3-p429
[~]$ gem in mysql2 [ruby-1.9.3-p429]
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/aselder/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** 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
--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/aselder/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/aselder/.rvm/gems/ruby-1.9.3-p429/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/aselder/.rvm/gems/ruby-1.9.3-p429/gems/mysql2-0.3.11/ext/mysql2/gem_make.out我还尝试了所有不同的命令行选项,让gem找到mysql安装:
例如gem install mysql2 -- gem
发布于 2013-08-30 02:08:02
我找到了这个答案,它解决了我的问题:Error installing mysql2: Failed to build gem native extension
引用:
在Ubuntu/Debian和其他使用aptitude的发行版上:
sudo apt-get install libmysql-ruby libmysqlclient-dev在Red Hat/CentOS和其他使用yum的发行版上:
sudo yum install mysql-devel在装有Homebrew的Mac OS X上:
brew install mysql我在debian上,在运行上面的命令后,我运行:
gem install mysql2它在np中起作用。
发布于 2013-10-19 00:13:52
我解决了在mysql服务器启动时安装gem的问题!
brew install mysql
mysql.server start
bundle install在ruby-1.9.3-p125下。
希望这能有所帮助
发布于 2013-06-26 02:29:11
尝试使用Homebrew安装mysql,并使用Bundler安装mysql2 gem。
brew update
brew install mysql将以下内容添加到您的Gemfile
gem "mysql2"运行:
bundle installhttps://stackoverflow.com/questions/17303195
复制相似问题