MySQL2 gem won't install

前端 未结 4 1084
情歌与酒
情歌与酒 2021-02-07 10:17

I have been trying to install Gitlab on my Ubuntu 12.04 server for a long time, and all goes well until I run bundle install.

It says it is unable to instal

4条回答
  •  余生分开走
    2021-02-07 10:48

    If you are using Windows 8+ x64, please look at the answer provided in the body of this question:

    Installing MySQL2 Gem on Windows

    EDIT

    To make downvoters happy, I'm copying the content of the linked question:

    1. Clean up: the reason you're here is that you're probably been trying to install this gem, and it has failed, so you have some cleanup to do: gem uninstall mysql2

    2. Download Ruby 2.0 64 bit for Windows:

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

    1. Run the installer. Note the directory it installs to, and make sure it's in the User PATH. go to

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

    and make sure the path to the bin directory of the ruby install directory is in the PATH environment variable for the LOCAL user (it's also OK if it's in the SYSTEM Path environment variable)

    1. Download the Ruby 2 64 bit Dev Kit:

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

    1. Run the installer and note the location of the install directory. The instructions say that once you're done with the install, you need to run the devkitvars.bat file to set the environment variables. This DOES NOT work for Windows 8.1. You need to repeat the instructions to set the local path described in #2 above, to set the path environment variable for the local user to add the ruby dev kit bin directory, and the ruby dev kit mingw bin directory. For example, if the dev kit was installed to c:\ruby2devkit, and you installed ruby2 to the C:\Ruby200-x64 directory, then your edit your path statement to look like this:

      C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin
      
    2. Next you need to install the mysql-connector. DO NOT download and run the self-installer. Instead, download the zip file and unpack it. Note the directory you unpacked it to (for the purposes of this post, let's assume you unpacked it to c:\mysql-connector:

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

    1. The libmysql.lib included in the MySQL Connector 64 bit is not compatible with the mingw64-gcc compiler. You need to generate mingw64 compatible libmysql.lib file.

    2. Download the tools you need

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

    3. Unzip this file to a local directory, let's assume that you unzipped it to c:\svm-map

    4. Edit the PATH environment path, as described earlier, to now look like this:

      C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib
      
    5. Generate the new mysql libraries:

      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. Install the gem as follows (note the use of forward slashes instead of backslashes, it will fail if you use backslashes):

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

    Hope this helps, and hopefully someone will pay attention to the few Windows 7/8.1 users who want to do Ruby on Rails development.

提交回复
热议问题