gem install mysql ...错误

时间:2010-11-01 10:04:40

标签: mysql ruby-on-rails macos gem homebrew

安装MySQL gem:

  $ export ARCHFLAGS="-arch i386 -arch x86_64"
  $ gem install mysql -- --with-mysql-config=/usr/local/bin/mysql_config

返回错误:

  ERROR:  While executing gem ... (NoMethodError)
  undefined method `spec' for nil:NilClass

我该如何解决?

的信息:

  $ brew list
  git       
  mysql     
  readline

  $ gem env
  RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/horace/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - http://rubygems.org/

  $ which mysql
  /usr/local/bin/mysql

  $ gem list
  *** LOCAL GEMS ***
  brewbygems (0.3.1)
  sqlite3-ruby (1.3.2)

谢谢!

编辑:

来自dtruss的输出:http://clomputing.com/temp/dtruss-gem-install-mysql.txt

2 个答案:

答案 0 :(得分:6)

对于Ubuntu(Maverick),需要安装

sudo apt-get install libmysqlclient-dev

然后运行

sudo gem install mysql

其他分配,首先

sudo apt-get install libmysqlclient-dev

并检查mysql_config的位置http://packages.ubuntu.com/

并运行

sudo gem install mysql --with-mysql-config=path/to/mysql_config

答案 1 :(得分:1)

也许尝试用strace运行它,看看问题是什么?

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

或者如果您使用的是Mac OS X.     dtruss gem install mysql --with-mysql-config = / usr / local / bin / mysql_config