简体   繁体   English

Snow Leopard ruby​​gems mysql2和MAMP配置在Rails问题上的Ruby

[英]Snow Leopard rubygems mysql2 and MAMP configuration for ruby on rails issue

This is my config: 这是我的配置:

rails 2.3.5 导轨2.3.5
ruby 1.8.7 红宝石1.8.7
gem 1.8.11 宝石1.8.11
mamp 2.0.3 (which uses Mysql 5.5) mamp 2.0.3(使用Mysql 5.5)

When creating a new rails project with mysql as the database, I get an error: 使用mysql作为数据库创建新的Rails项目时,出现错误:

An error occured while installing mysql2 (0.3.7), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.7'` succeeds before bundling.

I believe this is because gems can't find the MAMP mysql files. 我相信这是因为gems找不到MAMP mysql文件。 So a tutorial says I should download the MAMP libraries and compile it without server so I can then point the gem to those files. 因此,一个教程说我应该下载MAMP库并在没有服务器的情况下进行编译,以便随后将gem指向那些文件。 The problem is that all tutorials use ./configure which no longer works for Mysql 5.5, instead you have to use cmake. 问题在于,所有教程都使用./configure,而该版本不再适用于Mysql 5.5,而必须使用cmake。 This tutorial: http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2 mentions a way to do it using cmake, but this command fails for me: 本教程: http : //blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2提到了使用cmake进行此操作的方法,但是此命令失败我:

sudo port install cmake

can't find command port. 找不到命令端口。 So I tried with homebrew sudo brew install cmake which gives: 所以我尝试了自制sudo brew install cmake,它给出了:

Cowardly refusing to `sudo brew install'

So... What are my options? 所以...我有什么选择? Rails and rubygems all seem to work, it's just pointing it to the MAMP mysql libraries that I'm having a problem with, I'm very new to rails (started yesterday). Rails和rubygems似乎都可以工作,只是将其指向我遇到问题的MAMP mysql库,我对Rails还是很陌生(从昨天开始)。 Any help would be appreciated. 任何帮助,将不胜感激。

Thanks. 谢谢。

In the end, installing cmake without sudo (who would have thought?) did work: 最后,安装不带sudo的cmake(谁会想到的?)成功了:

brew install cmake 

Then I followed the instructions on this page: http://blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2 然后,我按照此页面上的说明进行操作: http : //blog.mirotin.net/35/mamp-1-9-5-mysql-5-5-9-and-ruby-mysql2

and everything seems to be working. 一切似乎都正常。 Also for those of us new to ruby on rails, you might need to edit config/database.yml and add the socket directive, pointing to the MAMP socket: 同样对于那些刚接触Ruby的人,您可能需要编辑config / database.yml并添加指向MAMP套接字的socket指令:

socket: /Applications/MAMP/tmp/mysql/mysql.sock 套接字:/Applications/MAMP/tmp/mysql/mysql.sock

Hope this helps someone else. 希望这对其他人有帮助。

PS PS
I'll be sure to mark this as answered and give me lots of credit for it, thereby showing appreciation for myself so I can answer my future questions! 我将确保将其标记为已回答,并为此给予我很多荣誉,从而对自己表示感谢,以便我可以回答我将来的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM