1
gem update --system
如果出现以下的报错,表示没有权限,去到第二步
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
2
sudo gem update --system
出现以下的提示,表示成功了
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.
RubyGems system software updated
3 移除国外的镜像
gem sources --remove https://rubygems.org/
4 添加国内的镜像
gem source -a https://gems.ruby-china.org/
4-1.错误
gem Error fetching https://gems.ruby-china.org/:
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
以上错误是因为ruby-china 更换了域名,换成https://gems.ruby-china.com即可
5 查看当前的镜像
gem sources -l
6 开始安装cocoapods
sudo gem install cocoapods
如果出现以下的情况,则是没有权限,跳至第七步
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
7
sudo gem install -n /usr/local/bin cocoapods
这个过程很漫长,有点耐心,去做点其他的事情....
等到出现以下的打印,就ok了
CocoaPods 1.4.0.beta.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.4.0.beta.1
Setup completed
8 pod search出现的问题
[!] Unable to find a pod with name, author, summary, or description matching `afn`
删除cocoapods的索引
rm ~/Library/Caches/CocoaPods/search_index.json
然后重新pod search的时候,会出发cocoapods重新下载索引
pod search AFNetworking
Creating search index for spec repo 'master'..
遇到的问题
1、更新
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ sudo gem install cocoapods -n/usr/local/bin
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
Password:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ sudo gem install cocoapods -n/usr/local/bin
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ gem sources --add https://gems.ruby-china.com
https://gems.ruby-china.com added to sources
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
Password:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
xiaodeMacBook-Pro:~ xiao$ gem sources
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
https://gems.ruby-china.com
xiaodeMacBook-Pro:~ xiao$ gem sources --remove https://gems.ruby-china.org/
https://gems.ruby-china.org/ removed from sources
xiaodeMacBook-Pro:~ xiao$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com
xiaodeMacBook-Pro:~ xiao$ sudo gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.7.7.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
xiaodeMacBook-Pro:~ xiao$
删除本地cocoapod然后重装
xiaodeMacBook-Pro:~ xiao$ which pod
/usr/local/bin/pod
xiaodeMacBook-Pro:~ xiao$ sudo rm -rf /usr/local/bin/pod
Password:
xiaodeMacBook-Pro:~ xiao$ gem list
*** LOCAL GEMS ***
activesupport (4.2.10)
bigdecimal (default: 1.2.8)
CFPropertyList (2.3.5, 2.2.8)
claide (1.0.2)
cocoapods (1.3.1)
cocoapods-core (1.3.1)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.3)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
did_you_mean (1.0.0)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.0.3)
i18n (0.9.0)
io-console (default: 0.4.5)
json (default: 1.8.3.1)
libxml-ruby (2.9.0)
minitest (5.8.5)
molinillo (0.5.7)
nanaimo (0.2.3)
nap (1.1.0)
net-telnet (0.1.1)
netrc (0.11.0)
nokogiri (1.5.6)
power_assert (0.2.6)
psych (default: 2.1.0.1)
rake (10.4.2)
rdoc (default: 4.2.1)
ruby-macho (1.1.0)
rubygems-update (2.7.7, 2.6.14)
sqlite3 (1.3.11)
test-unit (3.1.5)
thread_safe (0.3.6)
tzinfo (1.2.3)
xcodeproj (1.5.2)
xiaodeMacBook-Pro:~ xiao$ sudo gem uninstall cocoapods -v 1.3.1
Remove executables:
pod, sandbox-pod
in addition to the gem? [Yn] y
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
xiaodeMacBook-Pro:~ xiao$ sudo gem uninstall -n /usr/local/bin cocoapods -v 1.3.1
Remove executables:
pod, sandbox-pod
in addition to the gem? [Yn] y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.3.1
xiaodeMacBook-Pro:~ xiao$ pod search AFNetworking
-bash: pod: command not found
xiaodeMacBook-Pro:~ xiao$ sudo gem install cocoapods
Password:
Sorry, try again.
Password:
Fetching: cocoapods-core-1.5.3.gem (100%)
Successfully installed cocoapods-core-1.5.3
Fetching: cocoapods-deintegrate-1.0.2.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.2
Fetching: cocoapods-downloader-1.2.2.gem (100%)
Successfully installed cocoapods-downloader-1.2.2
Fetching: molinillo-0.6.6.gem (100%)
Successfully installed molinillo-0.6.6
Fetching: atomos-0.1.3.gem (100%)
Successfully installed atomos-0.1.3
Fetching: nanaimo-0.2.6.gem (100%)
Successfully installed nanaimo-0.2.6
Fetching: xcodeproj-1.7.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
xiaodeMacBook-Pro:~ xiao$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed xcodeproj-1.7.0
Fetching: cocoapods-1.5.3.gem (100%)
Successfully installed cocoapods-1.5.3
Parsing documentation for xcodeproj-1.7.0
Installing ri documentation for xcodeproj-1.7.0
Parsing documentation for cocoapods-1.5.3
Installing ri documentation for cocoapods-1.5.3
Done installing documentation for xcodeproj, cocoapods after 4 seconds
2 gems installed
xiaodeMacBook-Pro:~ xiao$ pod --verson
[!] Unknown option: `--verson`
Did you mean: --version?
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
Commands:
+ cache Manipulate the CocoaPods cache
+ deintegrate Deintegrate CocoaPods from your project
+ env Display pod environment
+ init Generate a Podfile for the current directory
+ install Install project dependencies according to versions from a
Podfile.lock
+ ipc Inter-process communication
+ lib Develop pods
+ list List pods
+ outdated Show outdated project dependencies
+ plugins Show available CocoaPods plugins
+ repo Manage spec-repositories
+ search Search for pods
+ setup Setup the CocoaPods environment
+ spec Manage pod specs
+ trunk Interact with the CocoaPods API (e.g. publishing new specs)
+ try Try a Pod!
+ update Update outdated project dependencies and create new
Podfile.lock
Options:
--silent Show nothing
--version Show the version of the tool
--verbose Show more debugging information
--no-ansi Show output without ANSI codes
--help Show help banner of specified command
xiaodeMacBook-Pro:~ xiao$ pod --version
1.5.3
xiaodeMacBook-Pro:~ xiao$ pod setup
Setting up CocoaPods master repo
$ /usr/bin/git -C /Users/xiao/.cocoapods/repos/master fetch origin --progress
remote: Enumerating objects: 124004, done.
remote: Counting objects: 100% (124004/124004), done.
remote: Compressing objects: 100% (205/205), done.
remote: Total 863826 (delta 123840), reused 123860 (delta 123784), pack-reused 739822
Receiving objects: 100% (863826/863826), 96.90 MiB | 6.01 MiB/s, done.
Resolving deltas: 100% (587148/587148), completed with 10677 local objects.
From https://github.com/CocoaPods/Specs
d7d26ef24b1..4e96020248e master -> origin/master
$ /usr/bin/git -C /Users/xiao/.cocoapods/repos/master rev-parse --abbrev-ref
HEAD
master
$ /usr/bin/git -C /Users/xiao/.cocoapods/repos/master reset --hard
origin/master
Checking out files: 100% (88470/88470), done.
HEAD is now at 4e96020248e [Add] AutoKeyboard 1.4.3
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 86259 and retry the command.
CocoaPods 1.6.0.beta.2 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.2
Setup completed
xiaodeMacBook-Pro:~ xiao$ pod search afn
Creating search index for spec repo 'master'.. Done!
[!] Skipping `MailCore2` because the podspec contains errors.
[!] Skipping `MiniPlengi` because the podspec contains errors.
[!] Skipping `OCast` because the podspec contains errors.
[!] Skipping `OCastReferenceDriver` because the podspec contains errors.
[!] Skipping `UriParser` because the podspec contains errors.
xiaodeMacBook-Pro:~ xiao$
2.pod install 运行后报错如下
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.
You can try adding it manually in `/Users/xiao/.cocoapods/repos` or via `pod repo add`.
解决:
pod repo add cocoapods https://github.com/CocoaPods/Specs.git