-1

When trying to run bundle install to install missing gems for a rails project. It is throwing the error below-

An error occurred while installing mysql2 (0.5.6), and Bundler cannot continue.

In Gemfile: mysql2

I tried deleting the gemfile.lock and also removing the specified version for mysql2 from the Gemfile but the same issue occurs.

The full log is as below-

>bundle install Fetching gem metadata from https://rubygems.org/........... Resolving dependencies... Fetching rubyzip 2.4.1 Installing mysql2 0.5.6 with native extensions Installing rubyzip 2.4.1 Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.6/ext/mysql2 C:/Ruby30-x64/bin/ruby.exe extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_gc_mark_movable()... yes checking for rb_wait_for_single_fd()... yes checking for rb_enc_interned_str() in ruby.h... yes *** 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=C:/Ruby30-x64/bin/$(RUBY_BASE_NAME) --with-openssl-dir --without-openssl-dir --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-mysql-config --without-mysql-config --with-mysqlclient-dir --without-mysqlclient-dir --with-mysqlclient-include --without-mysqlclient-include=${mysqlclient-dir}/include --with-mysqlclient-lib --without-mysqlclient-lib=${mysqlclient-dir}/lib --with-mysqlclientlib --without-mysqlclientlib C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError) from C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `collect' from C:/Ruby30-x64/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library' from extconf.rb:131:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.6/mkmf.log extconf failed, exit code 1 Gem files will remain installed in C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.6 for inspection. Results logged to C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.6/gem_make.out C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:125:in `run' C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:28:in `build' C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:193:in `build_extension' C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:227:in `block in build_extensions' C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:224:in `each' C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:224:in `build_extensions' C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/installer.rb:844:in `build_extensions' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/rubygems_gem_installer.rb:111:in `build_extensions' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/rubygems_gem_installer.rb:30:in `install' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/source/rubygems.rb:205:in `install' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/installer/gem_installer.rb:55:in `install' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/installer/gem_installer.rb:17:in `install_from_spec' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/installer/parallel_installer.rb:133:in `do_install' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/installer/parallel_installer.rb:124:in `block in worker_pool' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/worker.rb:62:in `apply_func' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/worker.rb:57:in `block in process_queue' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/worker.rb:54:in `loop' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/worker.rb:54:in `process_queue' C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.5.23/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads' An error occurred while installing mysql2 (0.5.6), and Bundler cannot continue. In Gemfile: mysql2 
2
  • seems to be an open issue github.com/brianmario/mysql2/issues/1180 Commented Jan 12 at 17:06
  • 2021. I'm sure that'll be fixed/ resolved any day now :) Commented Jan 12 at 22:46

1 Answer 1

1

I don't know what OS you are on. But on Linux you'd need to install something like(I had that error on a Debian server and fixed it with the following)...

sudo apt install libmariadb-dev 

I'm not on Mac, but on a Mac maybe:

brew install mysql 

You need a MySQL development package installed on your OS most likely.

Sign up to request clarification or add additional context in comments.

5 Comments

So they need to install MySQL dev package on WIndows. Read my last line "You need a MySQL development package installed on your OS most likely."
The last line covers my answer fine. Perhaps don't down vote people who have given legitimate/ correct answers. I guarantee if they install libmysql(whatever its called on WIndows) fixes that and you down voted me. People like you make me not want to bother on this site anymore. My answer is far more helpful than posting an open Github issue from 2021.
How you chose to spend your effort is clear enough
Yes, I don't spend my time voting people down who are trying to be helpful to others. Have a good day.
I am using Windows OS and already have MySQL development package installed. But still getting the issue

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.