使用Cocoapods提示错误 Abort trap: 6 解决方法,RubyGems淘宝镜像管理失效解决方法。

在一个升级了Mac Os版本到10.12.2,Xcode 版本升级到8.2.1 后的周末,在新建了一个新工程写Demo的时候发现自己的Cocoapods在Pod install时创建xcworkspace失败。

错误提示如下:

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: 6

查询网上解决方案有卸载掉所有cocopods版本,并安装新版本。

删除所有版本

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-trunk

安装新版本

gem install cocoapods --pre

在安装新版本的时候出现问题,提示在原淘宝的ruby环境下无法找到cocoapod内容

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_specs.4.8.gz)

在访问RubyGems镜像 淘宝网后发现:

RubyGems 镜像的管理工作以后将交由 Ruby China 负责,本站将不在继续维护,本站的维护者已经或即将参与到 Ruby China 镜像 的维护工作中,目前已将安装请求重定向到 Ruby China 镜像,请大家注意更换本地的 Gem Source。

切换方法

$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.org
# 请确保只有 gems.ruby-china.org
$ gem install rails

完成并安装好最新的Cocopods后,执行pod install依旧报错

localhost:Lottery Fuhanyu$ pod --version
1.1.1
localhost:Lottery Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing MBProgressHUD (1.0.0)
Generating Pods project
Abort trap: 6

继续进行尝试,企图尝试升级Ruby版本,当前机器Ruby版本为2.0.0。

localhost:Ping2_iOSClient Fuhanyu$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

查询可更新的Ruby版本

localhost:Ping2_iOSClient Fuhanyu$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-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
以下省略...

执行最新Ruby版本安装报错

localhost:Ping2_iOSClient Fuhanyu$ rvm install 2.2.4
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/osx/10.12/x86_64/ruby-2.2.4.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.2.4/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.

发现在执行brew update时出错,手动执行brew update

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/local

发现在Mac OS版本更新后Apple对于usr文件进行了权限设置,所以执行:

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 <wayneeseguin@gmail.com>, Michal Papis     <mpapis@gmail.com> [https://rvm.io/]

发现错误

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

依次执行

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/master

再次尝试手动执行brew update成功

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_REPOSITORY to /usr/local/Homebrew!**
Homebrew no 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/local

成功后执行Ruby版本升级rvm install 2.3.3(别问我为什么选这个版本233333)

localhost:local Fuhanyu$ rvm install 2.3.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.3.3.
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.....
Installing required 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.3.3, this may take a while     depending on your cpu(s)...
ruby-2.3.3 - #downloading ruby-2.3.3, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
省略...

赶快执行以下pod install试试,再看看Ruby版本是否已更新过

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 `<main>'
localhost:Lottery Fuhanyu$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]

提示Cocoapods不存在,可能是不知道再哪次尝试的时候又给删了,再安装一下。

localhost:Lottery Fuhanyu$ gem install cocoapods --pre

重新创建一个新项目尝试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.0.2)
Generating Pods project
Integrating client project

[!] Please close 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.

Success!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,298评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,701评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 107,078评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,687评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,018评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,410评论 1 211
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,729评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,412评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,124评论 1 239
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,379评论 2 242
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,903评论 1 257
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,268评论 2 251
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,894评论 3 233
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,014评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,770评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,435评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,312评论 2 260

推荐阅读更多精彩内容