Bundle install fails after adding gem "mysql2" and gem "reverse_markdown"

I’m trying to add “mysql2” and “reverse_markdown” to my fresh discourse container in “Gemfile” to migrate data with the ipb script.

bundle config unset deployment
bundle install

results with:

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

    current directory: /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/mysql2-0.5.5/ext/mysql2
/opt/bitnami/ruby/bin/ruby extconf.rb
checking for rb_absint_size()... *** 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=/opt/bitnami/ruby/bin/$(RUBY_BASE_NAME)
/opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:490:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:583:in `try_link0'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:601:in `try_link'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:812:in `try_func'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:1116:in `block in have_func'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:989:in `block in checking_for'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:354:in `block (2 levels) in postpone'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:324:in `open'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:354:in `block in postpone'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:324:in `open'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:350:in `postpone'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:988:in `checking_for'
        from /opt/bitnami/ruby/lib/ruby/3.2.0/mkmf.rb:1115:in `have_func'
        from extconf.rb:34:in `<main>'

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

  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0-static/mysql2-0.5.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/mysql2-0.5.5 for inspection.
Results logged to /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0-static/mysql2-0.5.5/gem_make.out

  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:118:in `run'
  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:27:in `build'
  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:186:in `build_extension'
  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:220:in `block in build_extensions'
  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in `each'
  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in `build_extensions'
  /opt/bitnami/ruby/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:845:in `build_extensions'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/rubygems_gem_installer.rb:72:in `build_extensions'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/source/rubygems.rb:200:in `install'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/installer/gem_installer.rb:54:in `install'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/installer/parallel_installer.rb:155:in `do_install'
/opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/installer/parallel_installer.rb:146:in `block in
worker_pool'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/worker.rb:62:in `apply_func'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/worker.rb:57:in `block in process_queue'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/worker.rb:54:in `loop'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/worker.rb:54:in `process_queue'
  /opt/bitnami/discourse/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.1/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

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

In Gemfile:
  mysql2

Bitnami is not supported.

You need to add the required libraries for mysql inside the container or machine running the import.

For a standard install you can use this template, or contrive to do it yourself inside the bitnami container. Or you can use a Install Discourse for development using Docker (there are also guides for Mac, Windows, and Linux).

6 Likes

Ah, a little bit weird. I thought bitnami is the official version.

The standard install is the official version. The bitnami image is developed and supported by bitnami, and very few people here have used it. If you need help with the Bitnami version, you’ll need to ask them about it.

4 Likes

Thank you for this information. Will switch.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.