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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1357997/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:22:28  来源:igfitidea点击:

Snow Leopard + Ruby 1.9.1 + MySQL Gem = Huge problems

mysqlrubymacosrubygems

提问by Sean McCleary

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.

我尝试了大约 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 位应用程序运行的。

I uninstalled the mysql gem. When I tried to install the gem with this command:

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

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.

我已经尝试了从以下链接中读到的所有内容。

  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
  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 和雪豹

Any ideas?

有任何想法吗?

回答by Jonathan Vaught

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.

Sean,我看到您在 rvm 下运行 Ruby 1.9.1。我在相同的设置(Snow Leopard、rvm、MySQL 64 位包)下遇到了同样的问题。所有替代 gem(mysqlplus、kwatch-mysql-ruby 等)都失败并出现相同的错误。

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.

我怀疑安装了 MySQL,但在系统默认 Ruby 下,一切都像冠军一样工作。所以我想知道 rvm 是否在某种程度上不是活动扳手。

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.

编辑:我想通了。我在升级到 Snow Leopard 之前安装了 rvm,所以我的 Ruby 1.9.1 安装需要重新编译。为了更好地衡量,我从头开始重新安装了 rvm。

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.)

(注意:在 rvm 下安装 gems 时不能使用 sudo,因为 rvm 通过修改 $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.)

(注意:我将 /usr/local/mysql/bin 添加到我的 $PATH 中,因此在安装 mysql gem 时我不必指定任何那些糟糕的命令行参数。)

The mysql gem installed without a hitch.

mysql gem 安装顺利。

回答by Georges

I solved this problem by installing MySQL from MacPorts and then running the same gem install command that you have up there.

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

So, first, uninstall the MySQL you have from the package:

因此,首先,从包中卸载您拥有的 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*

If you haven't done it yet, install MacPorts from here: http://www.macports.org/install.phpThere's a package for Snow Leopard.

如果您还没有安装 MacPorts,请从这里安装 MacPorts:http: //www.macports.org/install.php有一个用于 Snow Leopard 的软件包。

Install mysql5-devel from MacPorts:

从 MacPorts 安装 mysql5-devel:

sudo port install mysql5-server-devel

It'll do all the dependencies and then MySQL. Follow all the post-install steps that the installer recommends - start-up items, etc. The MySQL it installs is 64-bit.

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

Then install the MySQL gem with:

然后使用以下命令安装 MySQL gem:

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

Note the path changes there. MacPorts puts MySQL in different places.

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

You should be good to go.

你应该很高兴去。

回答by NateD

I tried all the above steps with no luck, but discovered a workaround (or whatever) using the mysqlplus gem instead of the mysql gem:

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

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

And now my MySQL ruby apps work like a charm in Snow Leopard.

现在我的 MySQL ruby​​ 应用程序在 Snow Leopard 中运行起来就像一个魅力。

回答by NateD

Installing XCode was the solution for me

安装 XCode 是我的解决方案

回答by NateD

Take a look at this post: http://jameseggers.com/post/185690322/fix-mysql-and-rails-on-snow-leopard. It shows how to get MySQL + Ruby on Rails + Snow Leopard all working perfectly.

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

回答by Ryan Michela

Found a great tutorial online for this.

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

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

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

Setting the PATHvariable was my problem.

设置PATH变量是我的问题。

回答by NeptunePhoenix

I had the same problem with mysql gem, rvm and ruby 1.9.1. As mentioned in my post at NeptunePhoenix, I had success by installing mysql via port.

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

回答by Scott

回答by VelLes

The fix with me was re-installing MySQL. I used the 64bit DMG installation version - 5.5.13 http://dev.mysql.com/downloads/mysql/

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