jekyll / jekyll-import

:inbox_tray: The "jekyll import" command for importing from various blogs to Jekyll format.
https://import.jekyllrb.com
MIT License
512 stars 315 forks source link

Problems when trying to install gem mysql2 (Docker container) #513

Closed redblue81 closed 1 year ago

redblue81 commented 1 year ago

Hello everyone, I am trying to use jekyll-import with docker, I have a container with jekyll standard image, and my database is a mariadb database. My mariadb local server is running in another docker container. I am on a Windows 11 machine.

When I try to run bundle update, I get this error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/gem/gems/mysql2-0.5.5/ext/mysql2
/usr/local/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.1.0 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=/usr/local/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
/usr/local/lib/ruby/3.1.0/mkmf.rb:1086:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError)

    paths = paths.flat_map {|path| path.split(File::PATH_SEPARATOR)}
                                       ^^^^^^
        from /usr/local/lib/ruby/3.1.0/mkmf.rb:1086:in `each'
        from /usr/local/lib/ruby/3.1.0/mkmf.rb:1086:in `flat_map'
        from /usr/local/lib/ruby/3.1.0/mkmf.rb:1086: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:

  /usr/gem/extensions/x86_64-linux-musl/3.1.0/mysql2-0.5.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/gem/gems/mysql2-0.5.5 for inspection.
Results logged to /usr/gem/extensions/x86_64-linux-musl/3.1.0/mysql2-0.5.5/gem_make.out

  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/ext/builder.rb:102:in `run'
  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:28:in `build'
  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/ext/builder.rb:171:in `build_extension'
  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/ext/builder.rb:205:in `block in build_extensions'
  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/ext/builder.rb:202:in `each'
  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/ext/builder.rb:202:in `build_extensions'
  /usr/local/lib/ruby/site_ruby/3.1.0/rubygems/installer.rb:843:in `build_extensions'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/rubygems_gem_installer.rb:72:in `build_extensions'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/source/rubygems.rb:207:in `install'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/installer/gem_installer.rb:54:in `install'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/worker.rb:62:in `apply_func'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/worker.rb:57:in `block in process_queue'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/worker.rb:54:in `loop'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/worker.rb:54:in `process_queue'
  /usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.25/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'

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

In Gemfile:
  mysql2

I searched online, and in many posts I read that I should install default-libmysqlclient-dev, but how can I do that?

Or anyway, how I can resolve this problem?

Thanks to anyone who answer me.

parkr commented 1 year ago

I'm not sure... Have you tried https://stackoverflow.com/a/20303831?

redblue81 commented 1 year ago

@parkr Thanks a lot! That trick worked for me!!