2011-03-05 135 views
1

嘿傢伙 我試圖從github獲取Railscasts source code。當我跑步時捆綁安裝,我得到這個錯誤:當我在Rails中運行軟件包安裝時發生錯誤

installing mysql2 (0.2.6) with native extensions /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:529:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

     /usr/local/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lm... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lz... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lsocket... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lnsl... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lmygcc... no 
checking for mysql_query() in -lmysqlclient... no 
*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers. Check the mkmf.log file for more 
details. You may need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --without-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/usr/local/bin/ruby 
    --with-mysql-config 
    --without-mysql-config 
    --with-mysql-dir 
    --without-mysql-dir 
    --with-mysql-include 
    --without-mysql-include=${mysql-dir}/include 
    --with-mysql-lib 
    --without-mysql-lib=${mysql-dir}/lib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-mlib 
    --without-mlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-zlib 
    --without-zlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-socketlib 
    --without-socketlib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-nsllib 
    --without-nsllib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 
    --with-mygcclib 
    --without-mygcclib 
    --with-mysqlclientlib 
    --without-mysqlclientlib 


Gem files will remain installed in /Users/yozloy/.bundler/tmp/61472/gems/mysql2-0.2.6 for inspection. 
Results logged to /Users/yozloy/.bundler/tmp/61472/gems/mysql2-0.2.6/ext/mysql2/gem_make.out 
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:507:in `block in build_extensions' 
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `each' 
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `build_extensions' 
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:156:in `install' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>' 
    from /usr/local/bin/bundle:19:in `load' 
    from /usr/local/bin/bundle:19:in `<main>' 
+0

請發佈mkmf.log文件,以便我們爲您提供幫助。可能你沒有安裝mysql庫。 – thomasfedb 2011-03-05 01:55:51

回答

4
sudo apt-get install --assume-yes mysql-server-5.1 mysql-client-5.1 libmysqlclient-dev 

這應該是所有你需要的mysql2寶石。

+0

你的代碼應該可以工作,但我使用的是Mac OSX,有沒有其他的選擇?我已經嘗試過mac端口,我應該安裝'ysql-server-5.1'' mysql-client-5.1'' libmysqlclient-dev'全部三個端口來完成這個工作嗎? – mko 2011-03-09 15:33:31

+0

Mac上的Homebrew應該是要走的路。它可能就像「brew安裝mysql」一樣簡單。看看這個:http://elouisyoung.blogspot.com/2010/12/fresh-mac-rails-development-setup-quick.html – mikewilliamson 2011-03-09 17:43:59

0

我假設你在OS X上,根據你的主目錄是/ Users/yozloy。你有沒有安裝xcode developer tools?這個包是編譯某些寶石所必需的。

+0

是的,我已經安裝了Xcode,問題是由於安裝MySQL不正確。 – mko 2011-03-09 15:35:22

1

感謝麥克..這對我的作品:)我使用Ubuntu,剛裝

的apt-get安裝--assume - 是mysql的服務器 - 5.1的MySQL客戶端-5.1的libmysqlclient-dev的

併爲我工作。

+0

謝謝,這也適用於我。 – 2011-07-11 07:10:40

相關問題