Snow Leopard + Ruby 1.9.1 + MySQL Gem = 巨大的问题
我尝试了大约 3-4 个小时,试图让 mysql gem 安装到雪豹上的 ruby 1.9.1.在我升级到雪豹之前,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 未修改:http://gems.rubyforge.org/latest_specs.4.8.gz获得 200 好:http://gems.github.com/latest_specs.4.8.gz安装 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构建原生扩展.这可能需要一段时间...错误:安装mysql时出错:错误:无法构建 gem 原生扩展./Users/sean/.rvm/ruby-1.9.1-p243/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config检查 mysql_ssl_set()... 是检查 rb_str_set_len()... 否检查 rb_thread_start_timer()... 否检查mysql.h ...是的创建 Makefile制作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/本地/mysql/下包括-g -Os -arch x86_64的-fno-共同-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno常见-02 -g -Wall -无括号 -fno-common -pipe -fno-common -o mysql.o -c mysql.c在/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby.h:32 包含的文件中,从 mysql.c:5:/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:在函数INT2NUM"中:/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:464:警告:由于数据类型范围有限,比较总是正确的/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:464:警告:由于数据类型范围有限,比较总是正确的/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:在函数UINT2NUM"中:/Users/sean/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/ruby.h:472:警告:由于数据类型范围有限,比较总是正确的mysql.c:在函数escape_string"中:mysql.c:290:错误:需要左值作为赋值的左操作数mysql.c:290:错误:需要左值作为赋值的左操作数mysql.c:在函数real_escape_string"中:mysql.c:434:错误:需要左值作为赋值的左操作数mysql.c:434:错误:需要左值作为赋值的左操作数make: *** [mysql.o] 错误 1Gem 文件将继续安装在/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1 以供检查.结果记录到/Users/sean/.gem/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out我已经尝试了从以下链接中阅读的所有内容.
- http://void-design.net/2009/08/05/ruby-191-mysql-and-a-snow-leopard/
- http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/
- Rails、MySQL 和雪豹
有什么想法吗?
解决方案肖恩,我看到你在 rvm 下运行 Ruby 1.9.1.我在相同的设置下遇到了同样的问题(Snow Leopard、rvm、MySQL 64 位包).所有备用 gem(mysqlplus、kwatch-mysql-ruby 等)都失败并出现相同的错误.
我怀疑安装了 MySQL,但在系统默认的 Ruby 下,一切都像冠军一样工作.所以我想知道 rvm 是否不是万能扳手.
我想通了.我在升级到 Snow Leopard 之前安装了 rvm,所以我的 Ruby 1.9.1 安装需要重新编译.为了更好地衡量,我从头开始重新安装了 rvm.
这就是我所做的:
sudo gem 卸载 rvmrm -rf ~/.gem须藤宝石安装 rvmrvm-安装rvm 安装 1.9.1rvm 1.9.1env ARCHFLAGS="-arch x86_64" gem install mysql
(注意:在 rvm 下安装 gems 时不能使用 sudo,因为 rvm 通过修改 $PATH 来工作.)
(注意:我将/usr/local/mysql/bin 添加到我的 $PATH 中,因此在安装 mysql gem 时不必指定任何那些糟糕的命令行参数.)
mysql gem 安装顺利.
I tried for about 3-4 hours trying to get the mysql gem to install for ruby 1.9.1 on snow leopard. The mysql gem used to work just fine on 1.9.1 before I upgraded to snow leopard. I uninstalled MySQL server and gem from my machine. I then downloaded and installed: mysql-5.1.37-osx10.5-x86_64.dmg. I have been able to assert that this new version I installed is running as a 64bit application.
I uninstalled the mysql gem. When I tried to install the gem with this command:
env ARCHFLAGS="-arch x86_64" gem install mysql --verbose -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I got this error:
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
I have tried everything I have read from the following links.
- http://void-design.net/2009/08/05/ruby-191-mysql-and-a-snow-leopard/
- http://www.schmidp.com/2009/06/14/rubyrails-and-mysql-on-snow-leopard-10a380/
- Rails, MySQL and Snow Leopard
Any ideas?
解决方案Sean, I see that you are running Ruby 1.9.1 under rvm. I'm having the same problem under the same setup (Snow Leopard, rvm, MySQL 64-bit package). All of the alternate gems (mysqlplus, kwatch-mysql-ruby, etc) fail with the same error.
I would suspect the MySQL install, but everything works like a champ under the system default Ruby. So I wonder if rvm isn't the monkey wrench somehow.
EDIT: I figured it out. I installed rvm before upgrading to Snow Leopard, so my Ruby 1.9.1 install needed to be recompiled. For good measure, I reinstalled rvm from scratch.
Here's what I did:
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
(NOTE: You cannot use sudo when installing gems under rvm, because rvm works by modifying $PATH.)
(NOTE: I added /usr/local/mysql/bin to my $PATH so I didn't have to specify any of those awful command-line args when installing the mysql gem.)
The mysql gem installed without a hitch.
相关文章