2012-04-07 9 views
47

私はRailsの3.2.3とmysql2の宝石をインストールしようとしていると、失敗しています:ERROR:(レール3.2.3でmysql2)宝石ネイティブ拡張を構築するために失敗しました

★ bundle install 
Fetching gem metadata from https://rubygems.org/......... 
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.2.0) 
Using activesupport (3.2.3) 
Using builder (3.0.0) 
Using activemodel (3.2.3) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.3) 
Using mime-types (1.18) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.3) 
Using arel (3.0.2) 
Using tzinfo (0.3.32) 
Using activerecord (3.2.3) 
Using activeresource (3.2.3) 
Using bundler (1.1.3) 
Using coffee-script-source (1.2.0) 
Using execjs (1.3.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.6.6) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.3) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.0.2) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

     /Users/rarneson/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes 
checking for rb_wait_for_single_fd()... 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 
    --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=/Users/rarneson/.rvm/rubies/ruby-1.9.3-p125/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/rarneson/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11 for inspection. 
Results logged to /Users/rarneson/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/ext/mysql2/gem_make.out 
An error occured while installing mysql2 (0.3.11), and Bundler cannot continue. 
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling. 

私は、インストールバンドルを実行していますよこれは私のGemfileにあります:

gem 'mysql2', '~> 0.3.11' 

私は現在MAMPを使ってMySQLを実行しています。私はこれが悪い考えで、私はバニラMySQlを実行する必要があるかどうかはわかりませんが、現在の問題は宝石をインストールしているようです。私はstackoverflow上のこれらの問題のかなりの数を見てきましたが、すべてが少し違っているように見えるか、または本当に複雑な解決策を持っています。私は行方不明のものがありますか?何かシンプル?あほらしいもの?必要に応じて、アウトファイルから追加情報を提供することができます。私はいくつかの人がSQLiteをdevとテストしてからMySQLでテストすることを読んだが、それはかなり恐ろしい考えのように聞こえる。

+0

私は、MySQLのライブラリやヘッダわから、利用できないmysql_configをコマンドを持っています。 .profileにMAMP/Library/binを追加しました。 mysql.hが見つからないので失敗しました。これはライブラリ/ヘッダの一部であると仮定していますか? –

答えて

1

私はちょうど新しいコピーをインストールすることになりましたMAMPを使用していないと、それはトリックでした。また、32ビット版ではなく64ビット版をインストールする必要がありました。 https://github.com/brianmario/mysql2/issues/8

から

17

これは主に起因するMySQLのヘッダの不足のために、MySQLの開発者は(mysqlの-develのは)

'libmysqlclientの-devの' パッケージは、あなたの場合

  • が欠落しているとき、通常、このエラーが来るをパッケージ化し、インストールしてみていますあなたは窓の上にある場合のLinux try this link
  • 上にあるこのurl might help you
+0

これは私を働いた!ありがとう! :) –

+1

リンクが死んでいる。 – Cyclonecode

127

はちょうどコンソール

sudo apt-get install mysql-client libmysqlclient-dev 

でこれをコピーして働いていました!

+2

Ubuntu12.04、2013年4月に私のために働いた –

+0

私のために働いた、ありがとう! – jpganz18

+0

また私のために働いた。 – erik404

0

CentOSの解決方法を説明しているこのスレッドErrors Installing mysql2 gem via the Bundlerに従うことができます。この問題は修正されます。もしあなたのOSでコマンドを微調整すれば、mysql2 gemを正常にインストールすることができます。

40

私は、MySQLをインストールするためにHomebrew for Macを使用:

brew install mysql 

それから私はmysql2の宝石をインストールするには、宝石のコマンドを使用:

sudo gem install mysql2 
+0

これは私が得ていた私のエラーメッセージを修正しました。 –

2

私はちょうどOS XシエラとMAMPを使用して、同じ問題に遭遇し、 Rails 5.私は正常に宝石をインストールしました

gem install mysql2 -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config 

その後、バンドルインストールは正常に動作しました。

0

私はこのエラーを得たとき、私は実行することによってこの問題を解決することができたが:

gem install devtools 
関連する問題