错误:未能构建gem本机扩展——安装mysql2错误

时间:2021-03-02 00:19:22

error while running bundle install

运行bundle安装时出错

Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
...
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

when i run Make sure that gem install mysql2 -v '0.3.11'.I still get the same error.

运行时请确保gem安装mysql2 -v '0.3.11'。还是一样的错误。

4 个解决方案

#1


88  

which OS are you using?

你在用哪个操作系统?

anyway if you are using ubuntu, from this https://github.com/brianmario/mysql2/issues/8 run:

无论如何,如果你正在使用ubuntu,从这个https://github.com/brianmario/mysql2/issues/8运行:

sudo apt-get install mysql-client libmysqlclient-dev

Otherwise for Mac users,(use brew to install) check this http://mxcl.github.com/homebrew/, or run:

否则,对于Mac用户(使用brew安装),请检查http://mxcl.github.com/homebrew/或运行:

brew install mysql

then

然后

sudo gem install mysql2

and for windows users check the link below for a solution. Error installing mysql2: Failed to build gem native extension

对于windows用户,请检查下面的链接以获得解决方案。安装mysql2:未能构建gem本机扩展

I would recommend to use the normal command prompt.

我建议使用正常的命令提示符。

#2


0  

Sometimes you need to update your Ruby library, run this code:

有时你需要更新你的Ruby库,运行以下代码:

sudo gem update --system

#3


0  

Error fixed..

错误修复. .

Try to install these packages..

试着安装这些软件包

sudo apt-get install libmysqlclient-dev

sudo apt-get安装libmysqlclient-dev

sudo apt-get install bundler

sudo apt-get安装打包机

After installing the bundler.. try with

安装后打包机。试着用

gem install mysql2

gem安装mysql2

Its working.. Cool :)

它的工作. .酷:)

#4


0  

If the stack trace includes this error:

如果堆栈跟踪包括此错误:

mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

Look at what version of ruby you're using with:

看看你使用的ruby版本:

ruby -v

Then install the correct version of ruby dev that goes with your version of ruby:

然后安装正确的ruby dev版本,与您的ruby版本一起使用:

sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-dev

Then:

然后:

gem install mysql2

#1


88  

which OS are you using?

你在用哪个操作系统?

anyway if you are using ubuntu, from this https://github.com/brianmario/mysql2/issues/8 run:

无论如何,如果你正在使用ubuntu,从这个https://github.com/brianmario/mysql2/issues/8运行:

sudo apt-get install mysql-client libmysqlclient-dev

Otherwise for Mac users,(use brew to install) check this http://mxcl.github.com/homebrew/, or run:

否则,对于Mac用户(使用brew安装),请检查http://mxcl.github.com/homebrew/或运行:

brew install mysql

then

然后

sudo gem install mysql2

and for windows users check the link below for a solution. Error installing mysql2: Failed to build gem native extension

对于windows用户,请检查下面的链接以获得解决方案。安装mysql2:未能构建gem本机扩展

I would recommend to use the normal command prompt.

我建议使用正常的命令提示符。

#2


0  

Sometimes you need to update your Ruby library, run this code:

有时你需要更新你的Ruby库,运行以下代码:

sudo gem update --system

#3


0  

Error fixed..

错误修复. .

Try to install these packages..

试着安装这些软件包

sudo apt-get install libmysqlclient-dev

sudo apt-get安装libmysqlclient-dev

sudo apt-get install bundler

sudo apt-get安装打包机

After installing the bundler.. try with

安装后打包机。试着用

gem install mysql2

gem安装mysql2

Its working.. Cool :)

它的工作. .酷:)

#4


0  

If the stack trace includes this error:

如果堆栈跟踪包括此错误:

mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

Look at what version of ruby you're using with:

看看你使用的ruby版本:

ruby -v

Then install the correct version of ruby dev that goes with your version of ruby:

然后安装正确的ruby dev版本,与您的ruby版本一起使用:

sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-dev

Then:

然后:

gem install mysql2