mysql2 icon indicating copy to clipboard operation
mysql2 copied to clipboard

Having issue when installing mysql2 gem on ubuntu 24.04

Open simogeo opened this issue 8 months ago • 6 comments

I'm using ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux] (installed with RVM) on Ubuntu 24.04 and I get this error when trying to install mysql2 :

bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Installing mysql2 0.5.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/ubuntu/.rvm/gems/ruby-3.1.0/gems/mysql2-0.5.6/ext/mysql2
/home/ubuntu/.rvm/rubies/ruby-3.1.0/bin/ruby -I /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0 -r
./siteconf20240601-64133-pej7bb.rb 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
-----
Cannot find library dir(s) 
-----
*** 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/ubuntu/.rvm/rubies/ruby-3.1.0/bin/$(RUBY_BASE_NAME)
	--with-openssl-dir
	--with-openssl-dir
	--with-openssl-include
	--without-openssl-include=${openssl-dir}/include
	--with-openssl-lib
	--without-openssl-lib=${openssl-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/ubuntu/.rvm/gems/ruby-3.1.0/extensions/x86_64-linux/3.1.0/mysql2-0.5.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-3.1.0/gems/mysql2-0.5.6 for inspection.
Results logged to
/home/ubuntu/.rvm/gems/ruby-3.1.0/extensions/x86_64-linux/3.1.0/mysql2-0.5.6/gem_make.out

  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
/home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:47:in `block in
build'
  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/tempfile.rb:317:in `open'
  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
/home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in
build_extensions'
  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
  /home/ubuntu/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/installer.rb:847:in `build_extensions'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/rubygems_gem_installer.rb:76:in
`build_extensions'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
  /home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/source/rubygems.rb:206:in `install'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/installer/gem_installer.rb:54:in
`install'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/installer/parallel_installer.rb:132:in
`do_install'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/installer/parallel_installer.rb:123:in
`block in worker_pool'
  /home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/worker.rb:62:in `apply_func'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/worker.rb:57:in `block in
process_queue'
  /home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/worker.rb:54:in `loop'
  /home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/lib/bundler/worker.rb:54:in `process_queue'
/home/ubuntu/.rvm/gems/ruby-3.1.0/gems/bundler-2.5.11/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

Mysql server is 8.0.36-2ubuntu3

I've also tried : gem install mysql2 -v '0.5.6' -- --srcdir=/var/lib/mysql gem install mysql2 -v '0.5.6' -- --srcdir=/lib/x86_64-linux-gnu

And : gem install mysql2 --with-mysql-dir=/lib/x86_64-linux-gnu/ but I get this error message :

ERROR: While executing gem ... (Gem::OptionParser::InvalidOption) invalid option: --with-mysql-dir=/lib/x86_64-linux-gnu

Thanks for your support

simogeo avatar Jun 01 '24 17:06 simogeo