【问题标题】:Not able to install gems "mysql2, mariadb 10.1" in Ubuntu 16.04 Xenial无法在 Ubuntu 16.04 Xenial 中安装 gem“mysql2,mariadb 10.1”
【发布时间】:2016-06-14 21:37:20
【问题描述】:

我有工作的 mariadb 10.1 服务器。 我在 ubuntu 16.04 上安装了 ruby​​ 2.3.0。 我安装了 libmariadbd-dev 和 libmariadbclient-dev。 当我尝试“gem install mysql2”时,收到一条消息:

Building native extensions with: '--with-mysql-dir=/usr/local/mysql'
This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20160615-5183-kj9yds.rb extconf.rb --with-mysql-dir=/usr/local/mysql
checking for ruby/thread.h... *** 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/bin/$(RUBY_BASE_NAME)2.3
/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
        from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
        from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
        from extconf.rb:16:in `<main>'

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

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/gem_make.out

我找不到如何构建这个 gem。

【问题讨论】:

标签: ruby-on-rails ruby mariadb mysql2 ubuntu-16.04


【解决方案1】:

这种情况下的宝石需要 3 包。

sudo apt-get install libnetcdf-dev libssl-dev libcrypto++-dev

【讨论】:

    【解决方案2】:

    这是针对mac的,但是你需要改变路径:

    gem uninstall mysql2
    

    安装 mariadb 10.1 和必要的 ssl 包,或者这可能不需要 然后检查库的路径和 tinal 文件夹是否具有相同的名称:

    bundle config --local build.mysql2 "--with-mysql-config=/usr/local/Cellar/mariadb@10.1/10.1.29/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
    

    或者没有 ssl 路径

    bundle config --local build.mysql2 "--with-mysql-config=/usr/local/Cellar/mariadb@10.1/10.1.29/bin/mysql_config
    

    或直接使用 gem,但如果你来自 mysql,最好使用 bundle

    gem install mysql2 -v 'x.y.z' -- --with-mysql-config=/usr/local/Cellar/mariadb@10.1/10.1.29/bin/mysql_config
    

    最后

    bundle install
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-20
      • 1970-01-01
      • 2014-10-20
      • 2020-12-08
      • 1970-01-01
      • 2018-12-04
      相关资源
      最近更新 更多