MySQL 错误:无法构建 gem 本机扩展 - 安装 mysql2 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19765290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR: Failed to build gem native extension - Error installing mysql2
提问by ben
error while running bundle install
运行 bundle install 时出错
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 install mysql2 -v '0.3.11'
.I 仍然得到相同的错误。
回答by ben
which OS are you using?
您使用的是哪个操作系统?
anyway if you are using ubuntu, from this https://github.com/brianmario/mysql2/issues/8run:
无论如何,如果您使用的是 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 userscheck 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.
我建议使用普通的命令提示符。
回答by Mohammed Sawaie
Sometimes you need to update your Ruby library, run this code:
有时您需要更新您的 Ruby 库,运行以下代码:
sudo gem update --system
回答by karthi kj
Try to install these packages:
尝试安装这些软件包:
sudo apt-get install libmysqlclient-dev
sudo apt-get install bundler
After installing the bundler, run:
安装捆绑程序后,运行:
gem install mysql2
回答by Odysseus Ithaca
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 版本相匹配的正确版本的 ruby dev:
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
回答by supar
This thread helped in installing mysql2
该线程有助于安装 mysql2
Github thread on installing mysql2 on OSX Mojave
关于在 OSX Mojave 上安装 mysql2 的 Github 线程
as mentioned in the thread I tried
如我尝试的线程中所述
$ bundle config build.mysql2 --with-opt-dir=/usr/local/opt/openssl