[英]ERROR: Error installing mysql2: ERROR: Failed to build gem native extension
我在嘗試為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
沒有任何錯誤。
安裝libmysqlclient-devel:
CentOS的/ Fedora的:
yum install -y libmysqlclient-devel
Ubuntu的:
apt-get install -y libmysqlclient-dev
蘋果電腦:
brew install mysql
希望能幫助到你。
嗨,這可能是因為兩個原因。
1)您沒有為該嘗試安裝mysql服務器
$ brew install mysql
2)當您嘗試為此嘗試安裝mysql2時未指定mysql_config
$ gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.6.24/bin/mysql_config
您需要先安裝MySQL服務器。 你現在可能沒有它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.