在雪豹中 gem 安装 mysql 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1366746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gem install mysql failure in Snow Leopard
提问by collimarco
I successfully installed MySql x86_64 in Snow Leopard and Ruby and Ruby Gems seems to be installed properly:
我在 Snow Leopard 和 Ruby 中成功安装了 MySql x86_64,并且 Ruby Gems 似乎安装正确:
$ which mysql /usr/local/mysql/bin/mysql $ which ruby /usr/bin/ruby $ which gem /usr/bin/gem $ mysql Your MySQL connection id is 404 Server version: 5.1.37 MySQL Community Server (GPL) $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] $ gem -v 1.3.5
Unfortunatly I get an error installing mysql gem:
不幸的是,我在安装 mysql gem 时遇到错误:
$ sudo gem update --system ... $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
回答by Jan Gorman
I think you should try to uninstall the old mysql gem first before recompiling
我认为您应该在重新编译之前先尝试卸载旧的 mysql gem
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
回答by collimarco
Installing the Xcode that's bundled with the Snow Leopard fixed the problem.
安装与 Snow Leopard 捆绑的 Xcode 解决了该问题。
回答by craig
For me, it was adding the UNIX Tools option (if I recalled the name accurately), which include the headers. When I installed XCode originally, I didn't include this component because I didn't think that I would be writing UNIX code. Little did I know...
对我来说,它添加了 UNIX Tools 选项(如果我没记错名字的话),其中包括标题。当初安装XCode的时候,没有包含这个组件,因为我没想到自己会写UNIX代码。我知道的很少...
回答by Ryan
If you've installed MySQL 5 using MacPorts, then use the command:
如果您已使用 MacPorts 安装 MySQL 5,请使用以下命令:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
回答by Chris
I had this problem when I updated to Lion. In this case, I when to the app store and downloaded the latest Xcode. Then I uninstalled and reinstalled the database.
当我更新到 Lion 时,我遇到了这个问题。在这种情况下,我什么时候到应用商店下载最新的 Xcode。然后我卸载并重新安装了数据库。
The issue had to do with a broken link during the update. Ruby likes to be in /System while Apple places ruby in /Developer.
该问题与更新期间断开的链接有关。Ruby 喜欢放在 /System 中,而 Apple 喜欢将 ruby 放在 /Developer 中。
回答by Chris
was stuck with same problem: Tried most of the solution's: At the end
遇到同样的问题:尝试了大部分解决方案:最后
Edit the app/config/database.yml, change the adapter to mysql2
编辑app/config/database.yml,将adapter改为mysql2
production:
adapter: mysql2
database: commissi_production
username: root
password: root
host: localhost
& run on terminal
& 在终端上运行
gem install activerecord-mysql2-adapter
Solved the problem.
解决了问题。