2013-01-05 12 views
15

Ho cercato di installare Gitlab sul mio server Ubuntu 12.04 per un lungo periodo di tempo, e tutto va bene fino a quando eseguo bundle install.MySQL2 gem non verrà installato

Si dice che non è possibile installare MySQL2 ma non fornisce alcun motivo o azione correttiva.

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. 
[email protected]:/home/gitlab/gitlab$ 
+2

Cosa dice il file 'mkmf.log'? – rudolph9

+0

Hai installato mysql-server? – apchester

+0

Questo potrebbe aiutare: http://stackoverflow.com/questions/4613116/difficulties-installing-mysql-gem-on-ubuntu – Zabba

risposta

51

Non vi dico un generico problema possibile:

Impossibile creare Makefile causa di qualche ragione, probabilmente la mancanza di librerie e/o le intestazioni necessarie. Controlla il file mkmf.log per ulteriori dettagli su . Potresti avere bisogno di opzioni di configurazione.

Questo è il tuo suggerimento.

Assicurarsi di aver installato il repository client MySQL, insieme al pacchetto "devel" associato. Lingue come Ruby, Python, Perl, ecc., Hanno bisogno di librerie e intestazioni installate in modo che possano compilare moduli nativi che forniscono l'interfaccia dalla lingua ai driver.

Inoltre, avrete bisogno di mysql_config, che viene installato da:

sudo apt-get install libmysqlclient-dev 

sono stato in grado di duplicare il vostro problema con il mio Ubuntu VM, e risolvere il problema dopo l'installazione di libmysqlclient-dev.

Inserisce mysql_config in /usr/bin/mysql_config ed entrambi gem install mysql e gem install mysql2 sono stati installati correttamente.

+1

E se hai mysql installato in un server completamente diverso, fai ancora bisogno di installare tutti questi pacchetti sul server che esegue rvm e rails? – JohnMerlino

+0

Ci sono due parti in MySQL, PostgreSQL o altre app client/server; Il software client e il software server. Se si è su un'altra macchina e si desidera scrivere codice per parlare con il server, allora sì, è necessario che il codice client sia installato. Come comunicherà il tuo codice al server se non ha accesso ai driver client per il server? –

+1

Ho avuto lo stesso problema sul mio MBP, ma la tua risposta mi ha aiutato. Dopo aver eseguito 'brew install mysql' sono stato in grado di eseguire' gem instal mysql2' con successo. – shovavnik

11

Grazie, ha funzionato, ha dovuto aggiungere solo una roba più Qualche

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

Hai detto che questa soluzione ha funzionato per te ma non gli hai dato l'assegno? Potresti accettare la sua risposta? – DutGRIFF

3

Ho usato questa soluzione per questo problema 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

Se sei utilizzando x64 di Windows 8 +, si prega di guardare la risposta fornita nel corpo di questa domanda:

Installing MySQL2 Gem on Windows

EDIT

Per rendere downvoters felice, sto copiando il contenuto della domanda legato:

  1. Pulire: la ragione per cui sei qui è che si sta probabilmente ho provato per installare questo gioiello, e ha fallito, quindi hai qualche ripulitura su do: gem uninstall mysql2

  2. Downloa d Rubino 2.0 a 64 bit per Windows:

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

  1. Eseguire il programma di installazione. Annota la directory in cui installa e assicurati che si trovi nel PERCORSO utente. andare a

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

e assicurarsi che il percorso della directory bin della directory ruby ​​installazione è nella variabile d'ambiente PATH per l'utente locale (è anche OK se è nella variabile d'ambiente PATH di sistema)

  1. Scarica il Ruby 2 Kit di sviluppo a 64 bit:

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

  1. Eseguire il programma di installazione e annotare il percorso della directory di installazione. Le istruzioni dicono che una volta terminata l'installazione, è necessario eseguire il file devkitvars.bat per impostare le variabili di ambiente. Questo NON funziona per Windows 8.1. È necessario ripetere le istruzioni per impostare il percorso locale descritto al punto 2 in alto, per impostare la variabile di ambiente del percorso per l'utente locale per aggiungere la directory bin del Ruby Dev Kit e la directory del Ruby Dev Kit per il mingw bin. Ad esempio, se il dev kit è stato installato in c: \ ruby2devkit, ed è stato installato ruby2 alla directory C: \ Ruby200-x64, quindi la tua modifica l'istruzione di percorso a guardare come questo:

    C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin 
    
  2. Poi si è necessario installare il connettore mysql. NON scaricare ed eseguire l'auto-installazione. Invece, scarica il file zip e decomprimilo. Si noti la directory si è spacchettato a (ai fini di questo post, supponiamo che si scompattato in c: \ mysql-connector:

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

  1. Il libmysql.lib incluso nel connettore MySQL 64 bit non è compatibile con il compilatore mingw64-gcc. È necessario generare un file libmysql.lib compatibile mingw64.

  2. Scarica gli strumenti necessari

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

  3. Decomprimere questo file in una directory locale, supponiamo che si è decompresso in c: \ SVM-map

  4. Modifica l'ambiente PATH percorso, come descritto in precedenza, per apparire in questo modo:

    C:\Ruby200-x64\bin;C:\ruby2-devkit\bin;c:\ruby2-devkit\mingw\bin;c:\svm-map;C:\svm-map\python-mingw-lib 
    
  5. G enerate le nuove librerie 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. Installare la gemma nel modo seguente (si noti l'uso di slash invece di backslash, si avrà esito negativo se si utilizza backslash):

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

Speranza questo aiuta, e si spera che qualcuno presterà attenzione ai pochi utenti di Windows 7/8.1 che vogliono fare lo sviluppo di Ruby on Rails.