本文介绍了“gem install mysql2”在Mac上用MAMP 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当试图在我当前目录(这是一个新的rails项目)中运行 rails server 时,它说我需要安装 mysql2 gem。起初,我不知道这是什么意思......然后,我做了一些探头,最后决定安装宝石。但是,我得到这个超级讨厌的错误(看到我刚刚花了2个小时试图调查,并解决了另一个错误)。我处于放弃的边缘,但我真的想尝试铁轨。请帮助!

When trying to run a rails server in my current directory (which is a new rails project), it says that I need to install the mysql2 gem. At first, I had no idea what this meant... Then, I did some poking around, and finally decided to install the gem. However, I am getting this super pesky error (seeing as I just spent 2 hours trying to investigate, and solve another error). I am on the brink of giving up, but I really want to try rails. Please help!

目前,如果我运行 sudo gem install mysql2 ,或者甚至有人告诉我要做(我有MAMP),它给了我以下错误:

Currently, if I run sudo gem install mysql2, or even as some people told me to do online, gem install mysql -- \ --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config (I have MAMP), it gives me the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /Users/vicky/.rvm/rubies/ruby-2.0.0-p247/bin/ruby 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()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /Applications/MAMP/Library/lib
-----
creating Makefile

make "DESTDIR="
compiling client.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1


Gem files will remain installed in /Users/username/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to /Users/username/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out


推荐答案

你有没有考虑过用homebrew()? MAMP代表Mac-Apache-MySQL-PHP(这是最重要的部分)。我建议你直接在你的盒子上安装MySQL(自制软件负责所有繁重的工作),然后我怀疑你安装那个gem会有困难。

Have you considered installing MySQL with homebrew (http://brew.sh/)? MAMP stands for Mac-Apache-MySQL-PHP (the last part of this being the most important). I would suggest just installing MySQL directly on your box (homebrew takes care of all the heavy lifting) and afterwards I doubt you'll have any difficulty installing that gem.

安装自制软件 -

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

运行 brew doctor 按照任何指示,然后安装MySQL,运行 brew install mysql 并按照它提供的任何设置用户的说明等等。

Run brew doctor follow any instructions and then afterwards to install MySQL run brew install mysql and follow any of the instructions it provides for setting up a user, etc...

=============更新==============

============= UPDATE ==============

所以你想要做的就是用brew这种方式来安装MySQL,然后以普通的方式安装gem - sudo gem install mysql2 假设这个工作正常,那么你将能够通过MAMP切换回旧的MySQL安装 -

SO, what you'll want to do is use brew this way to install MySQL and then install the gem in the normal fashion - sudo gem install mysql2 assuming this works, then you will be able to switch back to the old MySQL install through MAMP via -

sudo nano /etc/paths

然后将此行添加到顶部o f文件 -

then add this line to the top of the document -

/Applications/MAMP/Library/bin

重新启动你的终端,然后运行 mysql 来检查你是否正在使用MySQL的MAMP安装, '会很好去。

restart your terminal and then run mysql to double check that you are using the MAMP installation of MySQL, and you'll be good to go.

这篇关于“gem install mysql2”在Mac上用MAMP 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 06:14