【问题标题】:Ruby on Rails - Bundler MySQL Error: Failed to build gem native extensionRuby on Rails - Bundler MySQL 错误:无法构建 gem 原生扩展
【发布时间】:2014-01-21 12:54:15
【问题描述】:

我正在尝试创建一个新的 Rails 项目。当我运行bundle install 时,由于某种原因出现错误。谁能告诉我为什么会发生这个错误以及如何解决它?

我跑了:bundle install 结果:

Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using i18n (0.6.9)
Using rake (10.1.1)
Using minitest (4.7.5)
Using multi_json (1.8.2)
Using tzinfo (0.3.38)Using atomic (1.1.14)
 
Using builder (3.1.4)
Using erubis (2.7.0)Using rack (1.5.2)
 
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using bundler (1.5.0.rc.1)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using thor (0.18.1)Using hike (1.2.3)
 
Using json (1.8.1)
Using tilt (1.4.1)
Using sass (3.2.13)
Using thread_safe (0.1.3)
Using rack-test (0.6.2)
Using treetop (1.4.15)
Using coffee-script (2.2.0)
Using rdoc (3.12.2)
Using uglifier (2.4.0)Using sprockets (2.10.1)
 
Using activesupport (4.0.2)
Using mail (2.5.4)
Using sdoc (0.3.20)
Using actionpack (4.0.2)
Using jbuilder (1.5.3)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using railties (4.0.2)
Using sprockets-rails (2.0.1)
Using coffee-rails (4.0.1)
Using jquery-rails (3.0.4)
Using activerecord (4.0.2)
Using sass-rails (4.0.1)
Using turbolinks (2.1.0)
Using rails (4.0.2)
 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 
    /home/olcay/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... 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... 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
    --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=/home/olcay/.rbenv/versions/2.0.0-p353/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/
    --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}/
    --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/olcay/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to /home/olcay/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out
 
An error occurred while installing mysql2 (0.3.14), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.3.14'` succeeds before
bundling.

我跑了:gem install mysql2 -v '0.3.14' 结果:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.
 
    /home/olcay/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... 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... 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
    --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=/home/olcay/.rbenv/versions/2.0.0-p353/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/
    --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}/
    --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/olcay/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to /home/olcay/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out

我跑了:bundle install 结果:

Fetching gem metadata from https://rubygems.org/...........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.2)
Using atomic (1.1.14)
Using tzinfo (0.3.38)
Using builder (3.1.4)
Using erubis (2.7.0)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using bundler (1.5.0.rc.1)
Using hike (1.2.3)
Using thor (0.18.1)
Using json (1.8.1)
Using tilt (1.4.1)
Using sass (3.2.13)
Using thread_safe (0.1.3)
Using treetop (1.4.15)
Using coffee-script (2.2.0)
Using rdoc (3.12.2)
Using uglifier (2.4.0)
Using activesupport (4.0.2)
Using rack (1.5.2)
Using mail (2.5.4)
Using sdoc (0.3.20)
Using activemodel (4.0.2)Using jbuilder (1.5.3)
 
Using rack-test (0.6.2)Using sprockets (2.10.1)
 
Using activerecord (4.0.2)
Using actionpack (4.0.2)
Using actionmailer (4.0.2)
Using railties (4.0.2)
Using sprockets-rails (2.0.1)
Using coffee-rails (4.0.1)
Using jquery-rails (3.0.4)
Using rails (4.0.2)
Using sass-rails (4.0.1)
Using turbolinks (2.1.0)
 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 
    /home/olcay/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... 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... 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
    --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=/home/olcay/.rbenv/versions/2.0.0-p353/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/
    --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}/
    --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/olcay/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to /home/olcay/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out
 
An error occurred while installing mysql2 (0.3.14), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.3.14'` succeeds before
bundling.

不要标记为重复,只需发送问题的链接并告诉我删除此帖子即可。 我的操作系统是 Ubuntu。

【问题讨论】:

  • 什么操作系统?
  • @Cdub Ubuntu。这个评论长度限制太令人沮丧了!

标签: mysql ruby-on-rails ruby rubygems


【解决方案1】:

听起来你没有安装libmysqlclient-dev 包:

sudo apt-get install libmysqlclient-dev
gem install mysql2

那就试试吧:

bundle install

【讨论】:

    猜你喜欢
    • 2011-05-27
    • 1970-01-01
    • 2015-08-25
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 2023-03-19
    • 1970-01-01
    • 2011-01-11
    相关资源
    最近更新 更多