One weekend after upgrading Mac Os version to 10.12.2 and Xcode version to 8.2.1, I created a new project to write a Demo and found that my Cocoapods failed to create xcWorkspace during Pod install.

The error message is as follows:

localhost:Lottery Fuhanyu$ pod init
localhost:Lottery Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1. 0)
Installing MBProgressHUD (1.0. 0)
Generating Pods project
Abort trap: 6Copy the code

Check online solutions to uninstall all cocopods versions and install the new version.

Delete all Versions

gem uninstall cocoapods
gem uninstall cocoapods-core
gem uninstall cocoapods-deintegrate
gem uninstall cocoapods-downloader
gem uninstall cocoapods-plugins
gem uninstall cocoapods-search
gem uninstall cocoapods-stats
gem uninstall cocoapods-try
gem uninstall cocoapods-trunkCopy the code

Install the new version

gem install cocoapods --preCopy the code

A problem occurred while installing the new version, indicating that cocoapod content could not be found in the original Taobao Ruby environment

localhost:Lottery Fuhanyu$ sudo gem install cocopods
ERROR:  Could not find a valid gem 'cocopods'(> =0), here is why:
      Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/latest_specs4.8..gz)Copy the code

After visiting RubyGems mirror taobao found:

RubyGems image management will be handled by Ruby China, this site will not continue to maintain, the maintainer of this site has been or will be involved in Ruby China image maintenance, has redirected installation requests to Ruby China image, Please pay attention to change the local Gem Source.

Switching method

$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.org
# Please make sure it's only gems.ruby-china.org
$ gem install railsCopy the code

When the latest Cocopods is complete and installed, pod Install still fails

localhost:Lottery Fuhanyu$ pod --version
1.11.
localhost:Lottery Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1. 0)
Installing MBProgressHUD (1.0. 0)
Generating Pods project
Abort trap: 6Copy the code

Continue to try to upgrade the Ruby version, the current machine Ruby version is 2.0.0.

localhost:Ping2_iOSClient Fuhanyu$ ruby -v
ruby 2.0. 0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]Copy the code

Query for updatable Ruby versions

localhost:Ping2_iOSClient Fuhanyu$ rvm list known
# MRI Rubies
[ruby-]1.86.[-p420]
[ruby-]1.87.[-head] # security released on head
[ruby-]1.91.[-p431]
[ruby-]1.92.[-p330]
[ruby-]1.93.[-p551]
[ruby-]2.0. 0[-p648]
[ruby-]2.1[10.]
[ruby-]2.2[6.]
[ruby-]2.3[3.]
[ruby-]2.4[. 0-rc1] ruby-head...Copy the code

An error occurred during the latest Ruby installation

localhost:Ping2_iOSClient Fuhanyu$ rvm install 2.24.
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/osx/10.12/x86_64/ruby-2.24..tar.bz2
Checking requirements for osx.
Installing requirements for osx.
Updating system.Error running 'requirements_osx_brew_update_system ruby - 2.2.4',
showing last 15 lines of /Users/Fuhanyu/.rvm/log/1482803016_ruby-2.24./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.Copy the code

Error found while brew Update is being executed, execute brew Update manually

localhost:local Fuhanyu$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil or running Cocktail cleanup/optimizations
are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
sudo chown -R $(whoami):admin /usr/localCopy the code

Apple has set permissions for usr files after the Mac OS version update, so execute:

localhost:local Fuhanyu$ sudo chown -R $(whoami):admin /usr/local
localhost:local Fuhanyu$ brew update
warning: no common commits
^COne sec, just cleaning up
Already on 'master'
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master
localhost:local Fuhanyu$ rvm --version
rvm 1.28. 0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis     <[email protected]> [https://rvm.io/]Copy the code

Find the error

Failure while executing: git pull --ff --no-rebase --quiet origin     refs/heads/master:refs/remotes/origin/masterCopy the code

Executed in sequence

localhost:local Fuhanyu$ git remote add origin https://github.com/Homebrew/homebrew.git
localhost:local Fuhanyu$ git fetch origin
localhost:local Fuhanyu$ git reset --hard origin/masterCopy the code

Another attempt to manually execute brew Update succeeded

localhost:local Fuhanyu$ brew update
==> **Homebrew has enabled anonymous aggregate user behaviour analytics.**
**Read the analytics documentation (and how to opt-out) here:**
**  ****https://git.io/brew-analytics**

==> **Tapping homebrew/core**
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'. remote: Counting objects:3801, done.
remote: Compressing objects: 100% (3683/3683), done.
remote: Total 3801 (delta 20), reused 319 (delta 6), pack-reused 0
Receiving objects: 100% (3801/3801), 3.03 MiB | 120.00 KiB/s, done.
Resolving deltas: 100% (20/20), done.
Tapped 3677 formulae (3.830 files, 9.5M)
Updated 1 tap (caskroom/cask).
==> **Deleted Formulae**
caskroom/cask/brew-cask
==> **Migrating HOMEBREW_REPOSITORY (please wait)... ** ==> **Migrated HOMEBREW_REPOSITORYto /usr/local/Homebrew! ** Homebrewno longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
  sudo chown root:wheel /usr/localCopy the code

RVM install 2.3.3(don’t ask me why I chose this version 233333)

localhost:local Fuhanyu$ rvm install 2.33.
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.33..
Continuing with compilation. Please read 'rvm help mount' to get more information on binary     rubies.
Checking requirements for osx.
Updating Homebrew...
Installing requirements for osx.
Updating system. Installingrequired custom packages: homebrew/dupes homebrew/dupes.
Installing required packages: zlib, autoconf, automake, libtool, pkg-config, coreutils, zlib,     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/Fuhanyu/.rvm/rubies/ruby-2.33., this may take a while     depending on your cpu(s)...
ruby-2.33. - #downloading ruby-2.33., this may take a while depending on your connection. % Total % Received % Xferd Average SpeedTime    Time     Time  Current
                             Dload  Upload   Total   Spent    LeftSpeed to omit...Copy the code

Try the following pod install and see if the Ruby version has been updated

localhost:local Fuhanyu$ cd /Users/Fuhanyu/Desktop/My\ code/DEMO/Lottery 
localhost:Lottery Fuhanyu$ pod install
/Library/Ruby/Site/2.0.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem cocoapods   (>= 0.a) (Gem::GemNotFoundException)
 from /Library/Ruby/Site/2.0.0/rubygems.rb:298:in `activate_bin_path' from /usr/local/bin/pod:22:in `
       
'
localhost:Lottery Fuhanyu$ ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]Copy the code

Error: Cocoapods does not exist. Try again to delete the Cocoapods.

localhost:Lottery Fuhanyu$ gem install cocoapods --preCopy the code

Create a new project to try Cocoapods

localhost:Ping2_iOSClient Fuhanyu$ cd /Users/Fuhanyu/Desktop/My\ code/DEMO/CocoapodsTest 
localhost:CocoapodsTest Fuhanyu$ pod init
localhost:CocoapodsTest Fuhanyu$ vim podfile
localhost:CocoapodsTest Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing Masonry (1.02.)
Generating Pods project
Integrating client project[!]  Pleaseclose any current Xcode sessions and use `CocoapodsTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.Copy the code

Success!