ERROR:安装mysql2时出错。ERROR: 构建gem本地扩展失败[英] ERROR: Error installing mysql2: ERROR: Failed to build gem native extension

本文是小编为大家收集整理的关于ERROR:安装mysql2时出错。ERROR: 构建gem本地扩展失败的处理方法,想解了ERROR:安装mysql2时出错。ERROR: 构建gem本地扩展失败的问题怎么解决?ERROR:安装mysql2时出错。ERROR: 构建gem本地扩展失败问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我在尝试为 Rails 安装 gem install mysql2 -v '0.3.17' 时遇到了一些问题.当我尝试通过运行 gem install mysql2 -v '0.3.17' 或 gem install mysql2 -v '0.3.17' 来安装它时,它给了我以下错误:

ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.


Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the file for more
details.  You may need configuration options.

Provided configuration options:
    --with-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
    --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

Gem files will remain installed in `..../gems/ruby-1.9.3-p392/gems/mysql2-0.3.17 for inspection`.
Results logged to `.../gems/ruby-1.9.3-p392/extensions/x86_64-darwin-14/1.9.1/mysql2-0.3.17/gem_make.out`

如何解决这个问题并成功安装 mysql2?

谢谢大家.

推荐答案

我在 Ubuntu 15.04 中遇到了与上述相同的错误.

我做到了:

 sudo apt-get install libmysqlclient-dev 

在这之后我做了:

gem install mysql2

现在我可以成功了

rails new <app_name> -d mysql

没有任何错误.

本文地址:https://www.itbaoku.cn/post/786592.html