티스토리 뷰

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

    current directory: /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/mysql2-0.5.3/ext/mysql2
/home/pilseong/.rbenv/versions/2.7.5/bin/ruby -I /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0 -r ./siteconf20220119-39260-1xa00b9.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... 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=/home/pilseong/.rbenv/versions/2.7.5/bin/$(RUBY_BASE_NAME)
        --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
/home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError)
        from /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/mkmf.rb:1050:in `collect'
        from /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/mkmf.rb:1050:in `find_library'
        from extconf.rb:87:in `<main>'

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

  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/mysql2-0.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/mysql2-0.5.3 for inspection.
Results logged to /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/mysql2-0.5.3/gem_make.out

  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:99:in `run'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/ext_conf_builder.rb:48:in `block in build'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/tempfile.rb:291:in `open'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/ext_conf_builder.rb:30:in `build'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:169:in `block in build_extension'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:165:in `synchronize'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:165:in `build_extension'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:210:in `block in build_extensions'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:207:in `each'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/ext/builder.rb:207:in `build_extensions'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/installer.rb:844:in `build_extensions'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
  /home/pilseong/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'

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

In Gemfile:
  mysql2

 

해결책

https://discuss.rubyonrails.org/t/error-occurred-while-installing-mysql2/76210/3

You need to install the specific MySQL client dependencies. For example, on Ubuntu Linux:

sudo apt-get install libmysqlclient-dev

 

 

rbenv 설치

https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-20-04

728x90
댓글