gem install mysql failure in Snow Leopard

2019-01-15 08:21发布

I successfully installed MySql x86_64 in Snow Leopard and Ruby and Ruby Gems seems to be installed properly:

$ which mysql
/usr/local/mysql/bin/mysql
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem
$ mysql
Your MySQL connection id is 404
Server version: 5.1.37 MySQL Community Server (GPL)
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.5

Unfortunatly I get an error installing mysql gem:

$ sudo gem update --system
...
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.

6条回答
何必那么认真
2楼-- · 2019-01-15 08:45

For me, it was adding the UNIX Tools option (if I recalled the name accurately), which include the headers. When I installed XCode originally, I didn't include this component because I didn't think that I would be writing UNIX code. Little did I know...

查看更多
成全新的幸福
3楼-- · 2019-01-15 08:46

was stuck with same problem: Tried most of the solution's: At the end

Edit the app/config/database.yml, change the adapter to mysql2

  production:
  adapter: mysql2
  database: commissi_production
  username: root
  password: root
  host: localhost

& run on terminal

 gem install activerecord-mysql2-adapter

Solved the problem.

查看更多
Fickle 薄情
4楼-- · 2019-01-15 08:52

Installing the Xcode that's bundled with the Snow Leopard fixed the problem.

查看更多
贼婆χ
5楼-- · 2019-01-15 08:53

I think you should try to uninstall the old mysql gem first before recompiling

sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
查看更多
Anthone
6楼-- · 2019-01-15 08:57

I had this problem when I updated to Lion. In this case, I when to the app store and downloaded the latest Xcode. Then I uninstalled and reinstalled the database.

The issue had to do with a broken link during the update. Ruby likes to be in /System while Apple places ruby in /Developer.

查看更多
forever°为你锁心
7楼-- · 2019-01-15 09:07

If you've installed MySQL 5 using MacPorts, then use the command:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
查看更多
登录 后发表回答