How do I install the mysql ruby gem under OS X 10.

2020-07-10 06:11发布

Here is the deal.

$ gem --version

1.1.0

$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Bulk updating Gem source index for: http://gems.rubyforge.org/ ERROR: could not find mysql locally or in a repository

$ sudo gem update

Updating installed gems Bulk updating Gem source index for: http://gems.rubyforge.org/

Updating RedCloth ERROR: While executing gem ... (Gem::GemNotFoundException) could not find RedCloth locally or in a repository

I've tried this, this, this, this, and a ton of others.

None of them have worked for me. Is anyone else having this problem? If so what did you do to fix it that is not mentioned above?

标签: mysql ruby gem
5条回答
祖国的老花朵
2楼-- · 2020-07-10 06:30

Ryan Grove has a blog post with the answer:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
  --with-mysql-include=/usr/local/mysql/include
查看更多
\"骚年 ilove
3楼-- · 2020-07-10 06:32

Step 1

gem update --system

It probably won't provide the fix itself, but You really want rubygems 1.2. It will save you about 8 days waiting as it doesn't need to do the 'Bulk updating 102304 gems' rubbish any more

It actually looks like it can't find the mysql gem at all, let alone download or install it. You're not behind a proxy server or something weird like that?

If it's something to do with your rubygems or the net, rather than mysql specifically, then the gem update --system should reveal it too

查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-07-10 06:37

Installing XCode solved this problem for me.

This is because it includes the make and gcc tools, which are required by the gem.

查看更多
趁早两清
5楼-- · 2020-07-10 06:42

Do you have different ruby versions on your system? If you're running the Darwin-supplied ruby binary, but installed ruby gems under /usr/local, then you'll get errors like this. Even if you've aliased ruby to point to /usr/local, the gem command may fail if the proper ruby binary is not resolved correctly by your shell's $PATH. Also, if /usr/local/bin is located physically after /usr/bin in your path, gem will use /usr/bin/ruby to load the gems from /Library/Ruby/Gems/1.8/gems/. You may want to symlink /usr/lib/ruby/gems/1.8/gems to /Library/Ruby/Gems/1.8/gems/ to prevent this sort of thing.

查看更多
手持菜刀,她持情操
6楼-- · 2020-07-10 06:49

First of all as Orion Edwards said make sure you have rubygems 1.2. Unfortunately,

gem update --system

did not work for me.

Instead I had to:

  1. Manually download rubygems-update-1.2.0 from rubyforge.
  2. $ sudo gem install /path/to/rubygems-update-1.2.0.gem
  3. $ update_rubygems

Now that I had rubygems 1.2 I ran

$ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Everything is working. Thanks Orion Edwards for steering me in the right direction.

查看更多
登录 后发表回答