IT Share you

Bundler를 통한 mysql2 gem 설치 오류

shareyou 2020. 11. 29. 12:37
반응형

Bundler를 통한 mysql2 gem 설치 오류


mysql2들러를 통해 gem 을 설치하려고하는데 다음과 같은 오류로 계속 죽어갑니다.

** executing command
/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions': 
ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no

-----
mysql.h is missing.  please check your installation of mysql and try again.
-----

*** 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=/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
--with-mysql-config
Gem files will remain installed for inspection.

인터넷 검색을 통해 찾은 대부분의 경우 --with-mysql-config매개 변수를 전달하여 문제를 해결할 것을 권장 했습니다. 따라서 다음을 기반으로합니다.

$ which mysql_config
/usr/bin/mysql_config

Bundler의 구성에 다음을 추가했습니다.

$ bundle config build.mysql2 --with-mysql-config='/usr/bin/mysql_config'

그러나 여전히 운이 없습니다-위와 같은 충돌.

오류로 죽어 가고 있기 때문에 mysql.h is missing나는 그것을 확인했고 주변에 있다고 주장되며 Bundler에서 찾을 수 없습니다.

$ find / -name mysql.h
/usr/include/mysql5/mysql/mysql.h

이견있는 사람?


답변은 Wrikken이 게시 한 것과 비슷했습니다. 다음은 미래의 독자를 위해 수정 한 내용입니다.

(이것은 RHEL 5.5 용입니다-비슷하지만 Ubuntu / Debian / etc에 대해 다른 명령이 적용됩니다.)

그러면 sudo yum list installed컴퓨터에 설치된 모든 패키지가 인쇄됩니다 (참고 : yumRHEL에서는 Red Hat Network 저장소를 추가하고 [ EPEL 사용 ]을 통해 실행해야합니다 sudo).

내가 가지고 mysqlmysql-serverMySQL이 모든 기존 앱의 벌금을했다,하지만 어떤 이유를 설명하는 mysql-devel필요가있는, 즉 수정 mysql.h is missing오류 및 유사한 다른 빌드 오류를.

간단히 말해서, mysqldump -u root -ppassword --all-databases > full-dump.sql안전을 위해 간단한

sudo yum install mysql-devel

Ubuntu의 경우 다음을 설치해야합니다. libmysqlclient-dev libmysqlclient16


mysql의 양조 설치가있는 Mac의 경우 다음 솔루션으로 문제가 해결되었습니다.

/usr/local/Cellar/mysql/5.6.12/bin에서 mysql_config 파일을 편집하고 cflags 및 cxxflags에 대한 W- 컴파일러 옵션 -Wno-null-conversion 및 -Wno-unused-private-field를 제거했습니다.

This solved the problem with "gem install mysql2".

Reference: http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html


The above problem will be occured because the mysql-devel package is not properly installed in your system. I will be explain the same in Centos of how to fix it. When you try to install that package using,

    yum install mysql-devel

somtimes there will be some clash occurs with the existing packages that gets installed if you install the MySql-Administrative tool and MySQL query browser.

In that case, you need to uninstall all the existing mysql2 packages and install it again.

    rpm -qa -last | grep -i mysql
    yum remove MySQL-server-5.5.27-1.rhel5
    yum remove MySQL-client-5.5.27-1.rhel5
    yum remove mysql-gui-tools-5.0r12-1rhel4
    yum remove mysql-query-browser-5.0r12-1rhel4-a

So, you can uninstall whatever mysql things displayed with rpm -qa as like above.

Then you can install the mysql-server and mysql-client.

    yum install mysql-server
    yum install mysql-client

Now you do the installation of mysql-devel package.

    yum install mysql-devel

Now there is no package clashes and you can able to install the mysql2 gem.

    gem install mysql2 -v '0.3.11'

Now your mysql2 gem will be successfully installed and you are good to go.


In my case the problem was a misbehaving mysql_config script. When invoked by the command line with the --cflags option it would return a string of options containing:

-Xclang -target-feature -Xclang -aes -Qunused-arguments

For some reason the call to have_header('mysql.h') in the extconf.rb script would fail if those option were included.

What worked for me was to hand edit the mysql_config file removing the reference to those options from the line:

cflags="-I$pkgincludedir -Os -w -pipe -march=native -Xclang -target-feature -Xclang -aes -Qunused-arguments  -O2 -g -DDBUG_OFF " #note: end space!

which I rewrote as:

cflags="-I$pkgincludedir -Os -w -pipe -march=native  -O2 -g -DDBUG_OFF " #note: end space!

I got the same error. and for ubuntu 16. I had to write below command:

sudo apt-get install libmysqlclient-dev 

and it work back.


I know this is ancient, but if anyone still gets this zlib error, make certain that you typed: rvm use

(whatever version you're using)

I could have sworn I did that. Just posting in case anyone is pulling their hair out and this helps. If not good luck. :)


I ran into this issue while bundle installing for redmine on fedora 23. The solution I found was to issue this command - sudo dnf install redhat-rpm-config.

Not only did this fix my issue with installing mysql2, but also for nokogiri and redcarpet.


On my Ubuntu 16.04.4 LTS running mysql Ver 15.1 Distrib 10.0.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2, the following worked:

sudo apt-get install libmariadb-client-lgpl-dev

I saw, that the error message of the current installer suggests running

apt-get install libmysqlclient-dev

This might work as well.

참고URL : https://stackoverflow.com/questions/3754662/errors-installing-mysql2-gem-via-the-bundler

반응형