2012-02-03 46 views
7

我剛剛將我的RoR dev環境遷移到Ubuntu。我從github上下了一個項目,試圖安裝所有必要的gem。但是,每當我跑bundlebundle installbundle install exec我收到以下錯誤:我無法運行捆綁器,不斷收到錯誤

[email protected]:~/Workspace/SuitBrokers$ bundle install exec 
Fetching source index for http://rubygems.org/ 
Installing rake (0.9.2.2) 
Installing multi_json (1.0.3) 
Installing activesupport (3.1.0) 
Installing bcrypt-ruby (3.0.1) with native extensions 
Installing builder (3.0.0) 
Installing i18n (0.6.0) 
Installing activemodel (3.1.0) 
Installing erubis (2.7.0) 
Installing rack (1.3.5) 
Installing rack-cache (1.0.3) 
Installing rack-mount (0.8.3) 
Installing rack-test (0.6.1) 
Installing hike (1.2.1) 
Installing tilt (1.3.3) 
Installing sprockets (2.0.3) 
Installing actionpack (3.1.0) 
Installing mime-types (1.17.2) 
Installing polyglot (0.3.3) 
Installing treetop (1.4.10) 
Installing mail (2.3.0) 
Installing actionmailer (3.1.0) 
Installing arel (2.2.1) 
Installing tzinfo (0.3.31) 
Installing activerecord (3.1.0) 
Installing activeresource (3.1.0) 
Installing ansi (1.4.1) 
Using bundler (1.0.21) 
Installing cocaine (0.2.0) 
Installing coffee-script-source (1.1.3) 
Installing execjs (1.2.9) 
Installing coffee-script (2.2.0) 
Installing rack-ssl (1.3.2) 
Installing json (1.6.1) with native extensions 
Installing rdoc (3.11) 
Installing thor (0.14.6) 
Installing railties (3.1.0) 
Installing coffee-rails (3.1.1) 
Installing jquery-rails (1.0.18) 
Installing mysql (2.8.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /home/edu/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
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... yes 
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 
    --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=/home/edu/.rvm/rubies/ruby-1.9.2-p290/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 /home/edu/Workspace/SuitBrokers/exec/ruby/1.9.1/gems/mysql-2.8.1 for inspection. 
Results logged to /home/edu/Workspace/SuitBrokers/exec/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out 
An error occured while installing mysql (2.8.1), and Bundler cannot continue. 
Make sure that `gem install mysql -v '2.8.1'` succeeds before bundling. 

有沒有人處理這個特別的痛苦?您的幫助是永遠讚賞。

+0

您可以包括貓'輸出/home/edu/Workspace/SuitBrokers/exec/ruby/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out'? – Woahdae 2012-02-03 19:12:23

+0

該文件逐字說明輸出說在這行之後開始的內容「Gem :: Installer :: ExtensionBuildError:錯誤:無法構建gem本機擴展。」 – 2012-02-03 19:24:24

+0

但是,我沒有在ruby目錄中的任何地方看到extconf.rb .../bin/ruby​​ – 2012-02-03 19:27:01

回答

12

您需要告訴bundler在哪裏可以找到你的盒子上的mysql-dev東西。通常如下所示:

bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config 

當然,您需要將上面的路徑替換爲mysql_config的實際路徑。如果你沒有安裝mysql_config,那麼你需要在你的服務器上安裝mysql-dev軟件包。它看起來像你可能在共享服務器上,所以希望已經安裝了開發包。如果沒有,你需要請求它。

+0

謝謝@JasonK。我如何確定是否安裝了mysql-dev軟件包?我在哪裏尋找它?有沒有一個命令來運行?我正在使用安裝在運行Windows 7的Oracle虛擬機中的Ubuntu 11.10。 – 2012-02-03 23:42:54

+6

我相信Ubuntu上的這個軟件包叫做libmysqlclient-dev。所以安裝它的命令就像'sudo apt-get install libmysqlclient-dev' – JasonK 2012-02-06 15:23:15

+0

這對我來說沒有任何問題。謝謝。 – 2012-03-28 20:23:31

3

在Ubuntu 14.04(Trusty)上缺少的庫是:libmysqlclient-dev。下面 線的伎倆對我來說:

sudo apt-get install libmysqlclient-dev