报错信息:

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

或者:

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that `gem install mysql2 -v ‘0.5.3’ –source ‘https://rubygems.org/’` succeeds before bundling.

[redmine@server redmine-4.1.1]$ bundle install --path vendor/bundle
Fetching gem metadata from https://rubygems.org/............
Using rake 13.0.3
Using concurrent-ruby 1.1.8
Using i18n 1.6.0
Using minitest 5.14.4
Using thread_safe 0.3.6
Using tzinfo 1.2.9
Using activesupport 5.2.4.2
Using builder 3.2.4
Using erubi 1.10.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.10
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.9.1
Using rails-html-sanitizer 1.3.0
Using actionview 5.2.4.2
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 5.2.4.2
Using nio4r 2.5.7
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.3
Using actioncable 5.2.4.2
Using globalid 0.4.2
Using activejob 5.2.4.2
Using mini_mime 1.0.3
Using mail 2.7.1
Using actionmailer 5.2.4.2
Using method_source 1.0.0
Using thor 1.1.0
Using railties 5.2.4.2
Using actionpack-xml_parser 2.0.1
Using activemodel 5.2.4.2
Using arel 9.0.0
Using activerecord 5.2.4.2
Using mimemagic 0.3.10
Using marcel 0.3.3
Using activestorage 5.2.4.2
Using public_suffix 4.0.6
Using addressable 2.7.0
Using bundler 1.17.3
Using css_parser 1.9.0
Using csv 3.1.9
Using htmlentities 4.3.4
Using mini_magick 4.9.5
Fetching mysql2 0.5.3
Installing mysql2 0.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /redmine-4.1.1/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/ext/mysql2
/usr/local/rvm/rubies/ruby-2.6.6/bin/ruby -I /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210413-26657-inacke.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for -lmysqlclient... no
-----
mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.
-----
*** 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/rvm/rubies/ruby-2.6.6/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-mysql-dir
  --without-mysql-dir
  --with-mysql-include
  --without-mysql-include=${mysql-dir}/include
  --with-mysql-lib
  --without-mysql-lib=${mysql-dir}/lib
  --with-mysqlclientlib
  --without-mysqlclientlib

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

  /redmine-4.1.1/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/mysql2-0.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /redmine-4.1.1/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3 for inspection.
Results logged to /redmine-4.1.1/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/mysql2-0.5.3/gem_make.out

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  mysql2

解决办法:

#先导入mysql源文件,我用的是mysql5.7  5.7的源文件可在附件中下载。导入服务器后安装
#安装源文件
[redmine@server redmine-4.1.1]$ rpm -ivh mysql57-community-release-el7-8.noarch.rpm
#安装mysql_devel
[redmine@server redmine-4.1.1]$ sudo yum install mysql-devel

重新执行就好了。

打赏
分类: 文档

0 条评论

发表评论