web-dev-qa-db-ja.com

MySQL2gemがインストールされない

私は長い間Ubuntu12.04サーバーにGitlabをインストールしようとしてきましたが、bundle installを実行するまですべてうまくいきます。

MySQL2をインストールできないと表示されますが、理由や修正措置はありません。

home/gitlab/gitlab$ Sudo -u gitlab -H bundle install --deployment --without development test postgres
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/..
Using rake (10.0.1) 
Using i18n (0.6.1) 
Using multi_json (1.3.7) 
Using activesupport (3.2.9) 
Using builder (3.0.4) 
Using activemodel (3.2.9) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.1) 
Using actionpack (3.2.9) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.9) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.9) 
Using activeresource (3.2.9) 
Using bundler (1.2.3) 
Using rack-ssl (1.3.2) 
Using json (1.7.5) 
Using rdoc (3.12) 
Using thor (0.16.0) 
Using railties (3.2.9) 
Using Rails (3.2.9) 
Using acts-as-taggable-on (2.3.3) 
Using backports (2.6.5) 
Using bcrypt-Ruby (3.0.1) 
Using blankslate (3.1.2) 
Using sass (3.2.3) 
Using bootstrap-sass (2.2.1.1) 
Using carrierwave (0.7.1) 
Using charlock_holmes (0.6.9) 
Using chosen-Rails (0.9.8) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using coffee-Rails (3.2.2) 
Using colored (1.2) 
Using daemons (1.1.9) 
Using orm_adapter (0.4.0) 
Using warden (1.2.1) 
Using devise (2.1.2) 
Using diff-lcs (1.1.3) 
Using draper (0.18.0) 
Using escape_utils (0.2.4) 
Using eventmachine (1.0.0) 
Using multipart-post (1.1.5) 
Using faraday (0.8.4) 
Using ffaker (1.15.0) 
Using sass-Rails (3.2.5) 
Using font-awesome-sass-Rails (2.0.0.0) 
Using foreman (0.60.2) 
Using gemoji (1.2.1) 
Using git (1.2.5) 
Using posix-spawn (0.3.6) 
Using yajl-Ruby (1.1.0) 
Using pygments.rb (0.3.2) from https://github.com/gitlabhq/pygments.rb.git (at master) 
Using github-linguist (2.3.4) 
Using github-markup (0.7.4) 
Using gitlab_meta (4.0) 
Using gratr19 (0.4.4.1) 
Using grit (2.5.0) from https://github.com/gitlabhq/grit.git (at 7f35cb9) 
Using hashery (1.5.0) 
Using gitolite (1.1.0) 
Using grack (1.0.0) from https://github.com/gitlabhq/grack.git (at ba46f3b) 
Using hashie (1.2.0) 
Using multi_xml (0.5.1) 
Using rack-accept (0.4.5) 
Using rack-mount (0.8.3) 
Using virtus (0.5.2) 
Using grape (0.2.2) 
Using grit_ext (0.6.1) from https://github.com/gitlabhq/grit_ext.git (at 8e6afc2) 
Using haml (3.1.7) 
Using haml-Rails (0.3.5) 
Using httparty (0.9.0) 
Using httpauth (0.2.0) 
Using jquery-atwho-Rails (0.1.7) 
Using jquery-Rails (2.1.3) 
Using jquery-ui-Rails (2.0.2) 
Using jwt (0.1.5) 
Using kaminari (0.14.1) 
Using kgio (2.7.4) 
Using libv8 (3.3.10.4) 
Using modernizr (2.6.2) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/bin/Ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
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... yes
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=/usr/local/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 /home/gitlab/gitlab/vendor/bundle/Ruby/1.9.1/gems/mysql2-0.3.11 for inspection.
Results logged to /home/gitlab/gitlab/vendor/bundle/Ruby/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
root@Server:/home/gitlab/gitlab$
15
BMC

それはあなたに一般的な考えられる問題を教えてくれます:

何らかの理由でMakefileを作成できませんでした。おそらく、必要なライブラリやヘッダーが不足しています。詳細については、mkmf.logファイルを確認してください。構成オプションが必要になる場合があります。

それがあなたの手がかりです。

関連する「devel」パッケージとともに、MySQLクライアントリポジトリがインストールされていることを確認してください。 Ruby、Python、Perlなどの言語では、言語からドライバーへのインターフェイスを提供するネイティブモジュールをコンパイルできるように、ライブラリとヘッダーをインストールする必要があります。

また、次の方法でインストールされるmysql_configが必要です。

Sudo apt-get install libmysqlclient-dev

Ubuntu VMで問題を再現し、libmysqlclient-devをインストールした後に修正することができました。

Mysql_configを/usr/bin/mysql_configに配置し、gem install mysqlgem install mysql2の両方を正常にインストールできました。

52
the Tin Man

ありがとう、それはうまくいきました、ただいくつかの余分なものを追加する必要がありました

Sudo apt-get install libmysqld-dev libmysqlclient-dev mysql-client
12
BMC

Rails4でこの問題にこのソリューションを使用しました:(Ubuntu 12.04)

    1) Install MySQL from symptic manager just type "mysql-server-5.5" 
    2) use following command and install 
       Sudo apt-get install mysql-client libmysqlclient-dev
3
Rajnish

Windows 8+ x64を使用している場合は、この質問の本文に記載されている回答を参照してください。

WindowsへのMySQL2 Gemのインストール

[〜#〜]編集[〜#〜]

反対派を幸せにするために、私はリンクされた質問の内容をコピーしています:

  1. クリーンアップ:ここにいる理由は、おそらくこのgemをインストールしようとして失敗したため、クリーンアップを行う必要があるためです。gemuninstallmysql2

  2. Windows用のRuby 2.0 64ビットをダウンロード:

http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353-x64.exe?direct

  1. インストーラーを実行します。インストール先のディレクトリをメモし、ユーザーパスにあることを確認します。に行く

    Control Panel > System and Security > System - Advanced System Settings > Environment Variables
    

RubyインストールディレクトリのbinディレクトリへのパスがLOCALユーザーのPATH環境変数にあることを確認します(SYSTEM Path環境変数にある場合も問題ありません)。

  1. Ruby 264ビット開発キットをダウンロードします。

http://cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe

  1. インストーラーを実行し、インストールディレクトリの場所をメモします。インストールが完了したら、devkitvars.batファイルを実行して環境変数を設定する必要があると説明されています。これはWindows8.1では機能しません。上記の#2で説明したローカルパスを設定する手順を繰り返し、ローカルユーザーがRuby dev kitbinディレクトリとRuby dev kitmingwを追加するためのパス環境変数を設定する必要があります。 binディレクトリ。たとえば、開発キットがc:\ Ruby2devkitにインストールされ、Ruby2がC:\ Ruby200-x64ディレクトリにインストールされた場合、pathステートメントを次のように編集します。

    C:\Ruby200-x64\bin;C:\Ruby2-devkit\bin;c:\Ruby2-devkit\mingw\bin
    
  2. 次に、mysql-connectorをインストールする必要があります。セルフインストーラーをダウンロードして実行しないでください。代わりに、Zipファイルをダウンロードして解凍します。解凍したディレクトリに注意してください(この投稿では、c:\ mysql-connector:に解凍したと仮定します。

http://dev.mysql.com/downloads/file.php?id=450612

  1. MySQL Connector 64ビットに含まれているlibmysql.libは、mingw64-gccコンパイラと互換性がありません。 mingw64互換のlibmysql.libファイルを生成する必要があります。

  2. 必要なツールをダウンロードする

    https://structure-svm-map.googlecode.com/files/svm-map-win.Zip

  3. このファイルをローカルディレクトリに解凍します。c:\ svm-mapに解凍したと仮定します。

  4. 前に説明したように、PATH環境パスを編集して次のようにします。

    C:\Ruby200-x64\bin;C:\Ruby2-devkit\bin;c:\Ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib
    
  5. 新しいmysqlライブラリを生成します。

    cd c:\mysql-connector\lib
    
    gendef.exe libmysql.dll
    
    dlltool -v --dllname libmysql.dll --def libmysql.def --output-lib libmysql.lib
    
    copy libmysql.dll C:\Ruby200-x64\bin
    
    copy libmysql.lib C:\Ruby200-x64\bin
    
  6. 次のようにgemをインストールします(バックスラッシュの代わりにスラッシュを使用することに注意してください。バックスラッシュを使用すると失敗します):

    gem install mysql2 --platform=Ruby -- '--with-mysql-dir="C:/mysql-connector/"'
    

これがお役に立てば幸いです。そして、誰かがRuby開発でRailsを実行したい少数のWindows 7 /8.1ユーザーに注意を払うことを願っています。