查来查去查不到问题,后来在stackoverflow看到:

http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul/22384591#22384591

Issue already addressed by Ruby:

https://bugs.ruby-lang.org/issues/9624

now we just need to wait for Apple to update their ruby version (2.0.0p247) to the one after the latest one (2.0.0p451) which hasn't come out yet ... (or brew/macport it)
answered Mar 12 at 21:03 Sash

To address the issue you can install the most recent version of ruby as described by @Sash. You can use the following commands to do so. In case you already have installed rvm, you don't need to reinstall it.

#Install rvm
\curl -sSL https://get.rvm.io | bash -s stable #Install ruby version 2.0.0-p451
rvm install ruby-2.0.0-p451 #Print ruby version to verify that it was installed successfully
ruby -v #Install json gem
sudo gem install json
answered Mar 13 at 16:15 Lightforce

才发现可能是ruby版本问题。。

Last login: Sat May 17 08:35:42 on console

Narumis-MacBook-Air:~ narumi$ ruby -v

ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

Narumis-MacBook-Air:~ narumi$ rails -v

Rails 4.0.3

Narumis-MacBook-Air:~ narumi$ mysql -v

-bash: mysql: command not found

Narumis-MacBook-Air:~ narumi$ sudo gem install mysql2

Password:

Fetching: mysql2-0.3.16.gem (100%)

Building native extensions.  This could take a while...

ERROR:  Error installing mysql2:

ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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 /usr/local/mysql/bin/mysql_config

-----

checking for mysql.h... yes

checking for errmsg.h... yes

checking for mysqld_error.h... yes

-----

Setting rpath to /usr/local/mysql/lib

-----

creating Makefile

make "DESTDIR=" clean

make "DESTDIR="

compiling client.c

compiling infile.c

compiling mysql2_ext.c

compiling result.c

linking shared-object mysql2/mysql2.bundle

clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.16 for inspection.

Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.16/gem_make.out

Narumis-MacBook-Air:~ narumi$ bundle exec rails s

Could not locate Gemfile

Narumis-MacBook-Air:~ narumi$ bundle -v

Bundler version 1.6.0.rc

Narumis-MacBook-Air:~ narumi$ sudo bundle install

Could not locate Gemfile

Narumis-MacBook-Air:~ narumi$ sudo gem install mysql2 -v0.3.15

Fetching: mysql2-0.3.15.gem (100%)

Building native extensions.  This could take a while...

ERROR:  Error installing mysql2:

ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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 /usr/local/mysql/bin/mysql_config

-----

checking for mysql.h... yes

checking for errmsg.h... yes

checking for mysqld_error.h... yes

-----

Setting rpath to /usr/local/mysql/lib

-----

creating Makefile

make "DESTDIR=" clean

make "DESTDIR="

compiling client.c

compiling infile.c

compiling mysql2_ext.c

compiling result.c

linking shared-object mysql2/mysql2.bundle

clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15 for inspection.

Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/mysql2-0.3.15/gem_make.out

Narumis-MacBook-Air:~ narumi$

[Restored]

Narumis-MacBook-Air:~ narumi$ sudo gem install git

Password:

Fetching: git-1.2.6.gem (100%)

Successfully installed git-1.2.6

Parsing documentation for git-1.2.6

Installing ri documentation for git-1.2.6

1 gem installed

Narumis-MacBook-Air:~ narumi$ sudo gem install rvm

Fetching: rvm-1.11.3.9.gem (100%)

Successfully installed rvm-1.11.3.9

Parsing documentation for rvm-1.11.3.9

Installing ri documentation for rvm-1.11.3.9

1 gem installed

Narumis-MacBook-Air:~ narumi$ sudo gem install homebrew

ERROR:  Could not find a valid gem 'homebrew' (>= 0) in any repository

ERROR:  Possible alternatives: hebrew, homespree, homer, home_run, honeydew

Narumis-MacBook-Air:~ narumi$ sudo rvm install mysql2

sudo: rvm: command not found

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

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/man/man1/brew.1

==> The following directories will be made group writable:

/usr/local/.

==> The following directories will have their group set to admin:

/usr/local/.

Press RETURN to continue or any other key to abort

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/.

Password:

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/.

==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> Downloading and installing Homebrew...

remote: Counting objects: 172949, done.

error: RPC failed; result=56, HTTP code = 200

fatal: The remote end hung up unexpectedly

fatal: protocol error: bad pack header

Failed during: git fetch origin master:refs/remotes/origin/master -n

Narumis-MacBook-Air:~ narumi$ sudo ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Password:

Don't run this as root!

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

It appears Homebrew is already installed. If your intent is to reinstall you

should do the following before running this installer again:

rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

Narumis-MacBook-Air:~ narumi$ rm -rf /usr/local/.git

Narumis-MacBook-Air:~ narumi$ rm -rf /usr/local/brew

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

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort

==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

Password:

==> Downloading and installing Homebrew...

remote: Counting objects: 172949, done.

remote: Compressing objects: 100% (48276/48276), done.

remote: Total 172949 (delta 123533), reused 172949 (delta 123533)

Receiving objects: 100% (172949/172949), 33.78 MiB | 2.20 MiB/s, done.

Resolving deltas: 100% (123533/123533), done.

From https://github.com/Homebrew/homebrew

* [new branch]      master     -> origin/master

HEAD is now at 037e06d Move agedu to headonly

==> Installation successful!

==> Next steps

Run `brew doctor` before you install anything

Run `brew help` to get started

Narumis-MacBook-Air:~ narumi$ brew list

Narumis-MacBook-Air:~ narumi$ sudo chown -R $narumi /usr/loacal

Password:

usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...

chown [-fhv] [-R [-H | -L | -P]] :group file ...

Narumis-MacBook-Air:~ narumi$ sudo chown -R narumi /usr/loacal

chown: /usr/loacal: No such file or directory

Narumis-MacBook-Air:~ narumi$ sudo chown -R narumi /usr/local

Narumis-MacBook-Air:~ narumi$ sudo chown -R $narumi /usr/local

usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group] file ...

chown [-fhv] [-R [-H | -L | -P]] :group file ...

Narumis-MacBook-Air:~ narumi$ brew doctor

^C

Narumis-MacBook-Air:~ narumi$ brew doctor

Your system is ready to brew.

Narumis-MacBook-Air:~ narumi$ brew install mysql

==> Installing mysql dependency: openssl

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0.1g.mavericks.bottle.tar.g

######################################################################## 100.0%

==> Pouring openssl-1.0.1g.mavericks.bottle.tar.gz

==> Caveats

A CA file has been bootstrapped using certificates from the system

keychain. To add additional certificates, place .pem files in

/usr/local/etc/openssl/certs

and run

/usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in

parallel can cause all kinds of trouble.

The OpenSSL provided by OS X is too old for some software.

Generally there are no consequences of this for you. If you build your

own software and it requires this formula, you'll need to add to your

build variables:

LDFLAGS:  -L/usr/local/opt/openssl/lib

CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary

零零碎碎搞了一天最后发现是ruby版本问题的更多相关文章

  1. 关于IOS新手在安装cocoa pods失败,因为ruby版本过低的解决方法+ (void) {升级ruby}

    http://blog.csdn.net/zhaoen95/article/details/51995520     现在: 使用 OS 系统, 正在学习iOS 需要配置cocoapods 命令行中显 ...

  2. cocoapods安装以及使用,安装过程中ruby版本过低

    cocoapods安装以及使用,安装过程中ruby版本过低 字数473 阅读103 评论1 喜欢2 1.打开终端 2.移除现有 Ruby 默认源 $ gem sources --remove http ...

  3. macos下使用rvm管理ruby版本和rails版本

    1. 安装rvm curl -L https://get.rvm.io | bash -s stable 查看rvm 版本 2. 安装ruby rvm install 2.3.1 查看ruby 版本 ...

  4. 使用rvm关联ruby版本和rails版本。

    https://my.oschina.net/yudongyang/blog/1549248 https://rvm.io/gemsets 安装rails的一个版本 1.创建一个专门的文件夹存放对应的 ...

  5. 【Redis】安装 Redis接口时异常 ,系统ruby版本过低

    场景 操作系统Linux CentOS 7.2,安装Redis接口时,使用命令:gem install redis ,用于系统ruby版本过低,报错“redis requires Ruby versi ...

  6. MAC Ruby版本需要升级至2.2.2以上

    第一例: 默认情况下,Mac OS X 系统已经安装好 Ruby(最新的 Mavericks 随机的 Ruby 版本为 2.0.0p247),安装在 /System/Library/Framework ...

  7. macOS Ruby版本需要升级到2.2.2以上

    在安装 Ruby on Rails 时遇到问题,提示依赖 ruby 2.2.2 或更高的版本. ERROR: Error installing rails: activesupport require ...

  8. ruby版本错误的解决方法

    创建: 2018/09/18 完成: 2018/09/18 现在基本上不怎么开新博文了,目前着手的几个方面现有的博文已经全面覆盖.基本上都是更新原博,毕竟融合在一个页面里面方便自己工作使用. 遇到一些 ...

  9. 【转】如何在Mac 终端升级ruby版本

    原文网址:https://segmentfault.com/a/1190000003784636 rvm是什么?为什么要安装rvm呢,因为rvm可以让你拥有多个版本的Ruby,并且可以在多个版本之间自 ...

随机推荐

  1. Qt 学习之路 :Qt Quick Controls

    自 QML 第一次发布已经过去一年多的时间,但在企业应用领域,QML 一直没有能够占据一定地位.很大一部分原因是,QML 缺少一些在企业应用中亟需的组件,比如按钮.菜单等.虽然移动领域,这些组件已经变 ...

  2. android开发之service详解

    service作为android的四大组件之一,其重要性可想而知,在开发中,我们经常把一些不需要与用户进行交互的工作放在service中来完成,service运行在后台,这样有些人可能会产生错觉,以为 ...

  3. Java基础知识强化之集合框架笔记24:ArrayList存储自定义对象并遍历

    1. ArrayList存储自定义对象并遍历 2. 代码示例: Student.java,如下: package cn.itcast_01; public class Student { privat ...

  4. RHEL7重置root密码

    一.rd.break方法 在linux16那一段的最后,空一格输入rd.break 按Ctrl+启动到单用户模式,如下: 进去后输入命令mount,发现根为/sysroot/,并且不能写,只有ro=r ...

  5. Microsoft Windows Server 2008 R2 IIS7.5安装指南

    一.IIS安装步骤: 1.安装Windows Server 2008 R2(见 附录一) 2.配置计算机名称和IP地址(见 附录一) 3.配置成员服务器(见 附录一) 4.点击任务栏上的“服务器管理器 ...

  6. C#学习第一天

    主要看了一些关于C#的发展期情况,对这门语言有了初步的了解,下面慢慢道来. 首先是C#语言的特点,相比较其他的语言,C#具有以下突出的特点: 1.语法简洁,不允许直接操作内存,去掉了指针操作: 2.彻 ...

  7. 我是一块cpu 《转载》

    我是一块cpu,原装intel,在一台普通的台式计算机里供职.我有个小弟是内存,我要靠他时时刻刻陪伴我工作,其实有时候我并不是没有某某地址的资料,而是懒得翻--麻烦. 还有一个老大哥叫bios,每次那 ...

  8. SQL server 如何附加、还原、分离、备份数据库文件

    No1 : 附加 No2 : 还原            一.(需要 .bak文件)首先建立一个数据库,数据库名称与你的.bak文件名要相同. 当然.这时候的这个数据库还是空的,需要还原回去数据.右键 ...

  9. 数据库导出excel表数据

    - 执行之前 (错误) 消息 错误 0xc0202009: 数据流任务 1: SSIS 错误代码 DTS_E_OLEDBERROR.出现 OLE DB 错误.错误代码: 0x80040E37.  (S ...

  10. 一则自用iptables例子解释

    公网IP:110.24.3.83内网IP:10.252.214.186局域网数据库:10.252.214.100 通过NAT端口转发,访问110.24.3.83:3308端口跳转到局域网数据库机器的3 ...