Ruby on rails MySQL2创业板赢得';安装

Ruby on rails MySQL2创业板赢得';安装,ruby-on-rails,ruby,mysql2,gitlab,Ruby On Rails,Ruby,Mysql2,Gitlab,很长一段时间以来,我一直试图在我的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/..

很长一段时间以来,我一直试图在我的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$

它确实告诉您一个常见的可能问题:

由于某些原因无法创建Makefile,可能是缺少 必要的库和/或标题。查看mkmf.log文件了解更多信息 细节。您可能需要配置选项

那是你的线索

确保已安装MySQL客户端repo以及相关的“devel”包。Ruby、Python、Perl等语言需要安装库和头文件,以便编译本机模块,提供从语言到驱动程序的接口

此外,您还需要mysql_config,它由以下人员安装:

sudo apt-get install libmysqlclient-dev
我可以用我的Ubuntu虚拟机复制你的问题,并在安装libmysqlclient-dev后修复它


它将mysql_config放置在
/usr/bin/mysql_config
中,并且
gem install mysql
gem install mysql2
都能够成功安装。

谢谢,它成功了,只需添加一些额外的东西

sudo apt-get install libmysqld-dev libmysqlclient-dev mysql-client

我在rails4中使用了这个解决方案:(Ubuntu 12.04)


如果您使用的是Windows 8+x64,请查看此问题正文中提供的答案:

编辑

为了让选民高兴,我复制了相关问题的内容:

  • 清理:你来这里的原因是你可能一直在尝试 要安装此gem,它已失败,因此您需要进行一些清理 do:gem卸载mysql2

  • 下载适用于Windows的64位Ruby 2.0:

  • 运行安装程序。注意它安装到的目录,并确保它位于用户路径中。去

    Control Panel > System and Security > System - Advanced System Settings > Environment Variables
    
  • 并确保ruby安装目录的bin目录的路径在本地用户的path环境变量中(如果在系统path环境变量中也可以)

  • 下载Ruby 2 64位开发工具包:
  • 运行安装程序并记下安装目录的位置。说明中说,完成安装后,需要运行devkitvars.bat文件来设置环境变量。这不适用于Windows 8.1。您需要重复上面#2中描述的设置本地路径的说明,为本地用户设置path环境变量以添加ruby dev kit bin目录和ruby dev kit mingw bin目录。例如,如果dev kit安装到c:\ruby2devkit,而您将ruby2安装到c:\Ruby200-x64目录,则您的edit-your-path语句如下所示:

    C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin
    
    C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib
    
  • 接下来需要安装mysql连接器。请勿下载并运行自行安装程序。相反,下载zip文件并解压缩它。请注意您将其解压缩到的目录(在本文中,假设您将其解压缩到c:\mysql连接器:

  • MySQL连接器64位中包含的libmysql.lib与mingw64 gcc编译器不兼容。您需要生成与mingw64兼容的libmysql.lib文件

  • 下载您需要的工具

  • 将此文件解压缩到本地目录,假设您将其解压缩到c:\svm映射

  • 如前所述,编辑路径环境路径,使其看起来如下:

    C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin
    
    C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib
    
  • 生成新的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
    
  • 按如下方式安装gem(注意使用正斜杠而不是反斜杠,如果使用反斜杠将失败):


  • 希望这会有所帮助,希望有人会注意到少数希望进行Ruby on Rails开发的Windows 7/8.1用户。

    mkmf.log文件说明了什么?您安装了mysql服务器吗?这可能会有所帮助:如果您在完全不同的服务器上安装了mysql,您还需要安装所有这些软件包吗在运行rvm和rails的服务器上?MySQL、PostgreSQL或其他客户机/服务器应用程序分为两部分:客户机软件和服务器软件。如果您在另一台计算机上,希望编写代码与服务器通信,那么,是的,您必须安装客户机代码。如果服务器没有acce,您的代码将如何与服务器通信ss到服务器的客户端驱动程序?我的MBP上也有同样的问题,但你的回答帮助了我。在运行
    brew安装mysql
    后,我成功地运行了
    gem instal mysql2
    。你说这个解决方案对你有效,但你没有检查它。你能接受他的回答吗?