1. install cocoapods
| 1 | $ sudo gem install cocoapods | 
output error:
| 1 2 3 | ERROR:  Error installing cocoapods: activesupport requires Ruby version >= 2.2.2. | 
2. update ruby, install rvm ??
| 1 | curl -L get.rvm.io | bash -s stable | 
and check it:
| 1 2 3 | $ source ~/.bashrc $ source ~/.bash_profile $ rvm -v | 
| 1 | rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/] | 
uptate:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | $ rvm install 2.3.0 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.11/x86_64/ruby-2.3.0. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for osx. Installing requirements for osx. Updating system....... Error running 'requirements_osx_brew_update_system ruby-2.3.0', showing last 15 lines of /Users/wonpeace/.rvm/log/1474115683_ruby-2.3.0/update_system.log     https://github.com/Homebrew/homebrew/wiki/Common-Issues and make sure `brew update` works before continuing.' ++ rvm_pretty_print stderr ++ case "${rvm_pretty_print_flag:=auto}" in ++ case "${TERM:-dumb}" in ++ case "$1" in ++ [[ -t 2 ]] ++ return 1 ++ printf %b 'Failed to update Homebrew, follow instructions here:     https://github.com/Homebrew/homebrew/wiki/Common-Issues and make sure `brew update` works before continuing.\n' Failed to update Homebrew, follow instructions here:     https://github.com/Homebrew/homebrew/wiki/Common-Issues and make sure `brew update` works before continuing. ++ return 1 Requirements installation failed with status: 1. | 
yeah brew update:
| 1 2 3 4 5 6 7 8 9 10 | $ brew update /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError) 	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' 	from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>' 	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' 	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' 	from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>' 	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' 	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' 	from /usr/local/Library/brew.rb:15:in `<main>' | 
look here : https://github.com/Homebrew/legacy-homebrew/issues/49879
| 1 2 3 | $ sudo chown -R $(whoami):admin /usr/local $ cd $(brew --prefix) && git fetch origin && git reset --hard origin/master $ brew update | 
and update ruby:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | $ rvm install 2.3.1 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.11/x86_64/ruby-2.3.1. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for osx. Installing requirements for osx. Updating system..... Installing required packages: autoconf, automake, libtool, pkg-config, libyaml, readline, libksba, openssl......... Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date. Requirements installation successful. Installing Ruby from source to: /Users/wonpeace/.rvm/rubies/ruby-2.3.1, this may take a while depending on your cpu(s)... ruby-2.3.1 - #downloading ruby-2.3.1, this may take a while depending on your connection...   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100 13.7M  100 13.7M    0     0  1094k      0  0:00:12  0:00:12 --:--:-- 1327k ruby-2.3.1 - #extracting ruby-2.3.1 to /Users/wonpeace/.rvm/src/ruby-2.3.1.... ruby-2.3.1 - #configuring........................................................... ruby-2.3.1 - #post-configuration. ruby-2.3.1 - #compiling........... Error running '__rvm_make -j 1', showing last 15 lines of /Users/wonpeace/.rvm/log/1474116932_ruby-2.3.1/make.log compiling ./missing/setproctitle.c compiling dmyenc.c linking miniruby config.status: creating ruby-runner.c generating encdb.h dyld: lazy symbol binding failed: Symbol not found: _clock_gettime   Referenced from: /Users/wonpeace/.rvm/src/ruby-2.3.1/./miniruby (which was built for Mac OS X 10.12)   Expected in: /usr/lib/libSystem.B.dylib dyld: Symbol not found: _clock_gettime   Referenced from: /Users/wonpeace/.rvm/src/ruby-2.3.1/./miniruby (which was built for Mac OS X 10.12)   Expected in: /usr/lib/libSystem.B.dylib make: *** [encdb.h] Trace/BPT trap: 5 ++ return 2 There has been an error while running make. Halting the installation. | 
the error
| 1 | Error running '__rvm_make -j 1', | 
give up !
2.5 install ruby with brew
| 1 | brew install ruby | 
and set path, for you default root:
| 1 | vim .profile | 
add:
| 1 | export PATH=/usr/local/bin:$PATH | 
restart Terminal
| 1 2 | $ ruby -version ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] | 
is successed!
3. again!
| 1 | $ sudo gem install cocoapods | 
 
            
学习带来乐趣,谢谢博主!