Ruby gem mysql2 설치 실패
mysql2 gem을 설치하려고 할 때 명백한 오류없이 실패합니다. 누구든지 mysql2가 설치되도록이 문제를 해결하기 위해 무엇을해야하는지 알고 있습니까?
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-mysql-config
--without-mysql-config
--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-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
컴퓨터에 64 비트 MySQL과 xcode를 설치할 때 제공되는 빌드 도구가 설치되어 있어야합니다.
Ubuntu :
sudo apt-get install libmysqlclient-dev #(mysql development headers)
sudo gem install mysql2 -- --with-mysql-dir=/etc/mysql/
그게 다야!
결과:
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
mysql2가 제대로 컴파일하려면 MySQL 개발 헤더가 필요합니다. 많은 기능이 C로 작성되고 이후에 MySQL에 연결되기 때문에 필요합니다.
해결책은 gem 설치 프로그램을 mysql 설치 폴더에 명시 적으로 지정하는 것입니다.
gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
# or where ever you installed your mysql server to
또는 mysql 서버를 알려진 위치에 설치 (예 : homebrew 사용 ) 한 다음 gem을 설치합니다.
# install the mysql server locally
brew install mysql
# install the gem
gem install mysql2
두 가지 방법 모두 필요한 GCC 컴파일러를 사용하려면 XCode를 설치해야합니다.
With Brew and MySQL installed, I used the following to install the mysql2 gem
gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.10/bin/mysql_config
If you're using Bundler, you can tell bundler about this with command:
bundle config build.mysql2 --with-mysql-config=/usr/local//Cellar/mysql/5.5.10/bin/mysql_config
As documented here: http://gembundler.com/man/bundle-config.1.html
on Mac OSX Moutain Lion, below command worked for me:
gem install mysql2 -- --srcdir=/usr/local/mysql/include
Ubuntu 15.04:
sudo apt-get install libmysqlclient-dev
sudo gem install mysql2
Ubuntu-16.04:
sudo apt-get install ruby-mysql2
sudo gem install mysql2
Output:
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.19
Parsing documentation for mysql2-0.3.19
Installing ri documentation for mysql2-0.3.19
Done installing documentation for mysql2 after 0 seconds
1 gem installed
You might want to check this thread at the MySQL web site: http://forums.mysql.com/read.php?116,178217,178217, particularly the answer by Scott Derrick: http://forums.mysql.com/read.php?116,178217,189357#msg-189357
To be more specific, try using
sudo gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
Hope that helps.
I dug through 2 days worth of the internet and Stack Overflow, and it wasn't until I found this link and then starting working through this ticket for mysql2 that I actually resolved the issue.
With my setup (as explained in the ticket), the compiler switches of -Wno-null-conversion -Wno-unused-private-field would break and give me an error that wasn't exactly correct, which was:
mysql.h is missing. please check your installation of mysql and try again
I guess that if you type rvm use ruby-2.1.0@rails4.0 --create
in you directory then bundle install
it works.
I solved this by being specific on where are the directories, no need to reinstall anything, with brew or macports or whatever, just by specifying where are the things (only one thing: the ruby on my mac was installed with rvm, I'm not using the default one that comes with os x):
adding to your gem install mysql2
the flags below
--srcdir="..."
- the includes--with-mysql-dir="..."
- the mysql directory--with-mysql-config="..."
- the mysql_config file
like this gem install mysql2 --srcdir=/usr/local/mysql/include/ --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
In Centos 6.x (7 should work) with SCL (software collection) rh-mysql:
scl enable rh-mysql56 bash
gem install mysql2 -v '0.4.5' -- --with-mysql-include=/opt/rh/rh-mysql56/root/usr/include --with-mysql-lib=/opt/rh/rh-mysql56/root/usr/lib64
참고URL : https://stackoverflow.com/questions/4115126/ruby-gem-mysql2-install-failing
'IT TIP' 카테고리의 다른 글
파일 삭제를위한 MSBuild 작업 구문 (0) | 2020.10.30 |
---|---|
두 변수의 값을 바꾸는 PHP 함수가 있습니까? (0) | 2020.10.30 |
투명한 배경으로 UITableViewCell을 만드는 방법 (0) | 2020.10.30 |
솔트 생성 및 오픈 소스 소프트웨어 (0) | 2020.10.30 |
ArrayList에서 항목 이동 (0) | 2020.10.30 |