Snow Leopard + Ruby 1.9.1 + MySQL Gem =巨大的问题
我尝试了大约3-4个小时试图让雪豹在红宝石1.9.1上安装mysql gem。 在我升级到雪豹之前,在1.9.1上使用的mysql gem工作得很好。 我从我的机器上卸载MySQL服务器和宝石。 然后我下载并安装:mysql-5.1.37-osx10.5-x86_64.dmg。 我已经能够断言,我安装的这个新版本是作为64位应用程序运行的。
我卸载了MySQL的宝石。 当我试图用这个命令安装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
我已经尝试了我从以下链接阅读的所有内容。
有任何想法吗?
肖恩,我发现你在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安装没有问题。
我通过从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放在不同的地方。
你应该很好走。
我尝试了所有上述步骤,没有运气,但发现了一个解决方法(或其他)使用mysqlplus gem而不是mysql gem:
sudo env ARCHFLAGS="-arch x86_64" gem install mysqlplus
现在我的MySQL ruby应用程序就像Snow Leopard中的魅力一样。
链接地址: http://www.djcxy.com/p/33269.html