Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby ActiveRecord Basics Migrations and Relationships Migrations

Ben Rochon
Ben Rochon
18,996 Points

error on rails new biller -d mysql (*** extconf.rb failed ***)

When I run the rails new biller -d mysql, I get the following error.

Does anyone know what to do with that? Thanks

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.   /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150406-21600-1hwsk7c.rb 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... 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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

extconf failed, exit code 1

Gem files will remain installed in /var/folders/qt/6ch_f0fj5v36cvr_hshy1lq00000gn/T/bundler20150406-21600-virqee/mysql2-0.3.18/gems/mysql2-0.3.18 for inspection.
Results logged to /var/folders/qt/6ch_f0fj5v36cvr_hshy1lq00000gn/T/bundler20150406-21600-virqee/mysql2-0.3.18/extensions/universal-darwin-14/2.0.0/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.
         run  bundle exec spring binstub --all
/Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/resolver.rb:333:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine. (Bundler::GemNotFound)
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/resolver.rb:307:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/resolver.rb:307:in `verify_gemfile_dependencies_are_found!'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/resolver.rb:199:in `start'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/resolver.rb:182:in `resolve'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/definition.rb:193:in `resolve'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/definition.rb:132:in `specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/definition.rb:177:in `specs_for'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/definition.rb:166:in `requested_specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/environment.rb:18:in `requested_specs'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/runtime.rb:13:in `setup'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler.rb:122:in `setup'
    from /Library/Ruby/Gems/2.0.0/gems/bundler-1.9.1/lib/bundler/setup.rb:18:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'

1 Answer

  • sudo apt-get install libmysqlclient-dev
  • gem install mysql2 -v '0.3.18'