MySQL2 gem won't install

前端 未结 4 1082
情歌与酒
情歌与酒 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:33

    Thank you , It worked, had to just add a few extra stuff

    sudo apt-get install libmysqld-dev libmysqlclient-dev mysql-client
    
    0 讨论(0)
  • 2021-02-07 10:34

    I have used this solution for this problem in 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
    
    0 讨论(0)
  • 2021-02-07 10:46

    It does tell you a generic possible problem:

    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.

    That's your clue.

    Make sure you've installed the MySQL client repo, along with the associated "devel" package. Languages like Ruby, Python, Perl, etc., need the libraries and headers installed so they can compile native modules providing the interface from the language to the drivers.

    Also, you'll need mysql_config, which is installed by:

    sudo apt-get install libmysqlclient-dev
    

    I was able to duplicate your problem with my Ubuntu VM, and fix it after installing libmysqlclient-dev.

    It places mysql_config in /usr/bin/mysql_config, and both gem install mysql and gem install mysql2 were able to install successfully.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题