捆绑安装问题:mysql.h 丢失
在我的 mac OSX 10.6 32 位中,我可以很容易地安装 mysql2 gem,但不能在 mini mac 10.6 64 位服务器中安装。
我在麻烦的服务器上安装了 MySQL 5.5.11,而在我的家用 Mac 上安装了 MySQL 5.5.0.m2 不知何故,当我运行捆绑安装时,在服务器中它尝试在家庭 mysql2.0.2.6 中安装 mysql2.0.3.2
请不要告诉我
env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 --version '= 0.2.6' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
我试过了,不起作用。
在 $PATH 中包含 /usr/local/mysql/bin 也没有帮助。
错误代码:
Installing mysql2 (0.3.2) with native extensions /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/administrator/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... 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
--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/administrator/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2 for inspection.
Results logged to /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/ext/mysql2/gem_make.out
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:511:in `block in build_extensions'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `each'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `build_extensions'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:159:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/source.rb:96:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:55:in `block in run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `block in each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:44:in `run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:8:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/cli.rb:225:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/bin/bundle:13:in `<top (required)>'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `load'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `<main>'
in my mac OSX 10.6 32 bit, I can install mysql2 gem quite easily, but not in mini mac 10.6 64bit server.
I have installed MySQL 5.5.11 in troublesome server, while in my home mac MySQL 5.5.0.m2
Somehow when I run bundle install, in server it tries to install mysql2.0.3.2 while in home mysql2.0.2.6
Please don't tell me to
env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 --version '= 0.2.6' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I tried that, doesn't work.
Included /usr/local/mysql/bin in $PATH does not help as well.
Error code:
Installing mysql2 (0.3.2) with native extensions /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/administrator/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... 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
--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/administrator/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2 for inspection.
Results logged to /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/ext/mysql2/gem_make.out
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:511:in `block in build_extensions'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `each'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `build_extensions'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:159:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/source.rb:96:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:55:in `block in run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `block in each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:44:in `run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:8:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/cli.rb:225:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/bin/bundle:13:in `<top (required)>'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `load'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `<main>'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我尝试了这里发布的所有解决方案,但并不幸运。我用 homebrew 重新安装了 mysql 几次,但仍然没有成功。然后我发现一篇博客文章提供了解决方案。
我编辑了
/usr/local/Cellar/mysql/5.6.12/bin
中的 mysql_config 文件并删除W 编译器选项
-Wno-null-conversion
和-Wno-unused-private-field
对于 cflags 和 cxxflags。
这解决了
gem install mysql2
和bundle install
的问题参考:http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html
I tried all the solutions posted here, but was not lucky. I reinstalled mysql with homebrew a couple of times and still no luck. Then I came across a blog post with a solution.
I edited the mysql_config file in
/usr/local/Cellar/mysql/5.6.12/bin
and removedthe W-compiler options
-Wno-null-conversion
and-Wno-unused-private-field
for cflags and cxxflags.
This solved the problem with
gem install mysql2
andbundle install
Reference: http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html
我在 redmine 存储库上进行了捆绑安装,并收到了相同的错误消息:
运行 Fedora 16 64 位,我所做的就是从发行版 rpm 安装
mysql-devel
(开发包),问题就解决了!所以我认为你可以直接
或容易获取丢失的开发包。
I did a bundle install on a redmine repo and got the same error message :
Running Fedora 16 64 bits, all I did was install
mysql-devel
(development package) from the distro rpm and the problem was solved!So I think you could just
or apt-get the missing devel package.
对于没有使用brew安装mysql并使用mysql 5.6及更高版本的人:
根据这个答案
您需要编辑放置在我的案例中的
mysql_config
:/usr/local/mysql-5.6.12-osx10.7-x86_64/bin
并将
cflags
和cxxflags
更改为:在此操作
之后完美地
for people who didn't use brew to install mysql and use mysql 5.6 and higher:
according to this answer
you need to edit
mysql_config
which was placed in my case here:/usr/local/mysql-5.6.12-osx10.7-x86_64/bin
and change
cflags
andcxxflags
to:after this manipulations
goes flawlessly
好吧,对我来说,解决方案是:
来源:http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard
或者:
如果你的 mysql 版本是 64 位
之后我有一个很多问题,因为如果我想创建数据库:
我收到此错误:
解决方案是:在您的gemfile上添加:gem“ruby-mysql”
好的,一天半找到解决方案。
祝你今天过得愉快!
Ok guys for me the solution was:
source: http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard
OR :
If your mysql version is 64Bits
After that i had a lot of problems because if i want to create the database:
i was receiving this error:
The solution is: On your gemfile add: gem "ruby-mysql"
Ok, one day and a half to find the solution.
Have a nice day!
此方法适用于 64 位计算机上的 Rails 3.1.0(并希望更高版本)。我在 Ruby-1.9.2-p180 上使用。
这个博客回答了这个问题: http:// /www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/
基本上就是上面的方法: $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
可以工作,但没有捆绑程序。
要使用捆绑器执行此操作,首先必须在终端上运行它:
请注意该博客中所示的“mysql2”而不是“mysql”。
这会将配置添加到 ~/.bundle/config 文件
然后将其添加到 ~/.bash_profile:
这与告诉捆绑程序在本文顶部运行命令相同。
This method is for Rails 3.1.0 (and hopefully up) on 64 bit machine. I used on Ruby-1.9.2-p180.
This blog answered it: http://www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/
Basically, the method above: $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
may work, but without bundler.
To do it with bundler, first must run this on terminal:
Note "mysql2" not "mysql" as shown in that blog.
That adds a config to ~/.bundle/config file
Then add this to ~/.bash_profile:
That is the same with telling bundler to run the command on top of this post.
我可以让它工作的唯一方法是安装 x64 版本的 mysql。我刚刚使用了位于此处的 .dmg http://dev.mysql.com/downloads/mysql/ 它就像一个魅力。希望我能拿回解决这个问题所花费的 4 个小时。
The only way I could get this to work was to install the x64 version of mysql. I just used the .dmg located here http://dev.mysql.com/downloads/mysql/ and it worked like a charm. Wish I could get the 4 hours back it took to figure this out.
这对我的 Mac OSX Lion 有用:
这个博客回答了。
This worked for me on my Mac OSX Lion:
This blog answered it.
我的问题是首先通过可下载的二进制文件安装 MySql 的结果。它最初安装于版本 5.5.28。然后我尝试通过自制程序安装。 Brew 安装版本 5.6.x。然而,在通过自制程序安装的过程中,/usr/local/mysql 的符号链接仍然指向 5.5.28。
将符号链接更新为通过自制程序安装的版本。
例如:/usr/local/mysql -> /usr/local/Cellar/mysql/5.6.13/
这可能只是解决方案的一部分。
My problem was the result of first installing MySql via the downloadable binary. It was originally installed at version 5.5.28. I then attempted to install via homebrew. Brew installed version 5.6.x. HOWEVER in the process of installing via homebrew, the symlink for /usr/local/mysql was still pointed to 5.5.28.
Update your symlink to whichever version was installed via homebrew.
ex: /usr/local/mysql -> /usr/local/Cellar/mysql/5.6.13/
This could be just part of the solution.
对于mariadb:
则
可以成功安装。
For mariadb:
Then
could be successfully installed.
验证 gcc 是否已安装。如果不是,您将收到相同的错误消息。
您可以检查它提到的结果/日志文件,以获取有关原因的更多线索。
Verify that gcc is installed. If it isn't, you will get that same error message.
You can check the results/log file it mentions for more clues as to the cause.
我可以把这个贴在任何可以的地方——希望它能帮助别人并节省他们很多时间。
我花了两天的时间在互联网和 Stack Overflow 上进行了研究,直到我发现 此链接,然后开始处理 这张 mysql2 的票表明我实际上解决了这个问题。
根据我的设置(如票证中所述), -Wno-null-conversion -Wno-unused-private-field 的编译器开关会中断并给我一个不完全正确的错误,即:
Posting this wherever I can--hopefully it will help someone and save them a lot of time.
I dug through 2 days worth of the internet and Stack Overflow, and it wasn't until I found this link and then starting working through this ticket for mysql2 that I actually resolved the issue.
With my setup (as explained in the ticket), the compiler switches of -Wno-null-conversion -Wno-unused-private-field would break and give me an error that wasn't exactly correct, which was:
对于 Fedora 21 上的用户,并且您已经安装了 mysql-devel:
为我解决了问题。看:
红帽文档
For those on Fedora 21, and you already installed mysql-devel:
solved the problem for me. see:
redhat docs
TL;DR:
我被这个问题困扰了将近 2 天,并重新安装了
xcode
和mysql
多次。我最初使用
[email protected]
安装brew
,但bundle install
命令一直失败,因为它找不到mysql
安装。下面的错误输出:但是,使用@Kevin Boedigheimer的答案帮助解决了问题,即我链接了已安装的
[email protected]
到/usr/local/mysql
注意:如果您的 mysql 目录在其他地方,您可以使用以下命令找到它:
TL;DR:
I got stumped by this issue for almost 2 days and reinstalled
xcode
andmysql
so many times.I originally had
[email protected]
installed usingbrew
, but thebundle install
command kept failing because it could not find amysql
installation. Error output below:However, using @Kevin Boedigheimer's answer helped fixed the problem i.e. I linked the installed
[email protected]
to/usr/local/mysql
N.B: In case your mysql directory is somewhere else, you can find it using: