Snow Leopard + Ruby 1.9.1 + MySQL Gem =巨大的问题

时间:2009-08-31 15:25:16

标签: mysql ruby macos rubygems

我尝试了大约3-4个小时试图在雪豹上安装ruby 1.9.1的mysql gem。在我升级到雪豹之前,mysql gem曾经在1.9.1上运行得很好。我从我的机器上卸载了MySQL服务器和gem。然后我下载并安装:mysql-5.1.37-osx10.5-x86_64.dmg。我已经断言我安装的这个新版本是作为64位应用程序运行的。

我卸载了mysql gem。当我尝试使用此命令安装gem时:

env ARCHFLAGS="-arch x86_64" gem install mysql --verbose -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

我收到了这个错误:

GET 304 Not Modified: http://gems.rubyforge.org/latest_specs.4.8.gz
GET 200 OK: http://gems.github.com/latest_specs.4.8.gz
Installing gem mysql-2.8.1
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/COPYING
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/COPYING.ja
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/History.txt
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/Manifest.txt
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/README.txt
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/Rakefile
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/extconf.rb
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/mysql.c
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/extra/README.html
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/extra/README_ja.html
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/extra/tommy.css
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/lib/mysql.rb
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/tasks/gem.rake
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/tasks/native.rake
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/tasks/vendor_mysql.rake
/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/test/test_mysql.rb
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

/Users/sean/.rvm/ruby-1.9.1-p243/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

make
gcc -I. -I/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/i386-darwin9.8.0 -I/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward -I/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/mysql/include  -g -Os -arch x86_64 -fno-common   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common  -O2 -g -Wall -Wno-parentheses  -fno-common -pipe -fno-common  -o mysql.o -c mysql.c
In file included from /Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby.h:32,
                 from mysql.c:5:
/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h: In function 'INT2NUM':
/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h: In function 'UINT2NUM':
/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:472: warning: comparison is always true due to limited range of data type
mysql.c: In function 'escape_string':
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c: In function 'real_escape_string':
mysql.c:434: error: lvalue required as left operand of assignment
mysql.c:434: error: lvalue required as left operand of assignment
make: *** [mysql.o] Error 1


Gem files will remain installed in /Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

我已尝试过以下链接中的所有内容。

  1. http://void-design.net/2009/08/05/ruby-191-mysql-and-a-snow-leopard/
  2. http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/
  3. Rails, MySQL and Snow Leopard
  4. 有什么想法吗?

9 个答案:

答案 0 :(得分:15)

Sean,我看到你在rvm下运行Ruby 1.9.1。我在相同的设置下遇到了同样的问题(Snow Leopard,rvm,MySQL 64位软件包)。所有备用宝石(mysqlplus,kwatch-mysql-ruby等)都失败并出现相同的错误。

我怀疑MySQL安装,但一切都像系统默认Ruby下的冠军一样。所以我想知道rvm不是那种猴子扳手。

编辑: 我弄清楚了。我在升级到Snow Leopard之前安装了rvm,因此需要重新编译我的Ruby 1.9.1安装。为了更好的衡量,我从头开始重新安装了rvm。

这就是我的所作所为:

sudo gem uninstall rvm
rm -rf ~/.gem
sudo gem install rvm
rvm-install
rvm install 1.9.1
rvm 1.9.1
env ARCHFLAGS="-arch x86_64" gem install mysql

(注意:在rvm下安装gems时不能使用sudo,因为rvm通过修改$ PATH来工作。)

(注意:我将/ usr / local / mysql / bin添加到我的$ PATH中,所以在安装mysql gem时我没有必要指定任何可怕的命令行参数。)

安装的mysql gem没有任何障碍。

答案 1 :(得分:10)

我通过从MacPorts安装MySQL然后运行你在那里的相同gem install命令解决了这个问题。

所以,首先,从包中卸载你的MySQL:

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*

如果您还没有完成,请从此处安装MacPorts:http://www.macports.org/install.php Snow Leopard有一个包。

从MacPorts安装mysql5-devel:

sudo port install mysql5-server-devel

它将完成所有依赖项,然后是MySQL。遵循安装程序建议的所有安装后步骤 - 启动项目等。它安装的MySQL是64位。

然后安装MySQL gem:

env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5

注意那里的路径发生了变化。 MacPorts将MySQL放在不同的地方。

你应该好好去。

答案 2 :(得分:3)

我没有运气尝试了上述所有步骤,但发现使用mysqlplus gem而不是mysql gem的解决方法(或其他):

sudo env ARCHFLAGS="-arch x86_64" gem install mysqlplus

现在我的MySQL ruby​​应用就像Snow Leopard中的魅力一样。

答案 3 :(得分:1)

安装XCode是我的解决方案

答案 4 :(得分:1)

看一下这篇文章:http://jameseggers.com/post/185690322/fix-mysql-and-rails-on-snow-leopard。它展示了如何让Rails + Snow Leopard上的MySQL + Ruby完美运行。

答案 5 :(得分:1)

在线为此找到了一个很棒的教程。

http://www.icoretech.org/2009/08/install-mysql-and-mysql-ruby-gem-on-snow-leopard-64-bit/

设置PATH变量是我的问题。

答案 6 :(得分:1)

我遇到了与mysql gem,rvm和ruby 1.9.1相同的问题。正如我在 NeptunePhoenix的帖子中所提到的,我通过端口安装mysql取得了成功。

答案 7 :(得分:1)

在磕磕绊绊之前挣扎了好几个小时:

http://markgandolfo.com/2010/08/21/mysql-gem-with-rails-3-and-ruby-1-9-2

答案 8 :(得分:0)

我的修复是重新安装MySQL。我使用的是64位DMG安装版本 - 5.5.13 http://dev.mysql.com/downloads/mysql/