簡體   English   中英

在Rails 4中安裝MySQL gem時出錯

[英]Error installing MySQL gem in Rails 4

由於某種原因,我在安裝MySQL gem時遇到了問題,而過去卻並非如此。 我嘗試過一些沒有成功的事情。 如:

將源'https://rubygems.org'更改為源'http://rubygems.org'

還安裝gem install mysql

以及sudo apt-get install mysql-devgem install mysql

這是錯誤:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/kaka/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20150701-13627-kzmz5m.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... 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=/home/kaka/.rbenv/versions/2.2.2/bin/$(RUBY_BASE_NAME)
    --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-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

extconf failed, exit code 1

Gem files will remain installed in /home/kaka/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18 for inspection.
Results logged to /home/kaka/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.

有人可以幫我嗎?

我是否應該先安裝mySQL服務器才能安裝此gem?

首先安裝mysql客戶端/服務器:sudo apt-get install mysql-server libmysqlclient-dev mysql-client libmysqld-dev mysql-common

簡短答案: brew install mysql && bundle

長答案

我沒有安裝正確的mysql時遇到此錯誤。 我決定看看mysql在哪里,所以我跑了

$ which mysql
mysql: aliased to nocorrect mysql

后來我做了一些搜索,發現type mysql是一種更好的方法,因為它會告訴我上面的錯誤是zsh將mysql別名為“ nocorrect mysql”的特定問題。

無論如何,以為我沒有mysql,我運行brew install mysql並重新打包以解決問題。 因此問題得以解決,但是如果我運行which mysql它仍然會響應“ nocorrect mysql”。 因此,今天的課程是使用類型而不是類型。 在安裝gem之前也要安裝mysql。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM