1、檢測RVM是否安裝git
使用命令:$rvm -vgithub
結果:rvm 1.27.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]說明你應經安裝RVM了,否者就要安裝了:api
$ curl -L get.rvm.io | bash -s stable
//須要等一會
source ~/.bashrc
source ~/.bash_profile
rvm -v ,若是能顯示版本則安裝成功
2、檢測Ruby是否安裝
這裏不僅是檢測Ruby安裝的問題,還要看Ruby的版本是否大於2.2.2,否則會報錯:Error installing pods: activesupport requires Ruby version >= 2.2.2。
輸入命令$ruby -v ,出現版本信息:ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
或者使用命令:$rvm list 輸出信息爲:rvm rubies
ruby-2.0.0-p648 [ x86_64 ]
ruby-2.3.0 [ x86_64 ]
=* ruby-2.3.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
若是低於2.2.2則升級版本:
$rvm list known //列出ruby可安裝的版本信息
$rvm install 2.3.1 //安裝一個ruby版本 rvm 2.3.1 --default //設置ruby2.3.1爲系統默認版本
可能會碰到:
Error running 'requirements_osx_brew_update_system ruby-2.3.1',ruby
showing last 15 lines of /Users/max-pc/.rvm/log/1479699089_ruby-2.3.1/update_system.logbash
https://github.com/Homebrew/homebrew/wiki/Common-Issuescurl
and make sure `brew update` works before continuing.'fetch
這是提示咱們Brew 須要更新了ui
3、更新brew updatethis
Brew是OS X上相似apt-get以及yum的一個軟件包管理器,它依託於Github,這個具體是安裝仍是更細我當時怎麼整的也忘了,就是要用新的,卸載從新安裝,我感受比較好。url
可是當升級完Brew以後,可能會出現
Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError)
from /Library/Ruby/Site/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 /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/brew.rb:15:in `<main>'
這個問題我在知乎(知乎地址:https://www.zhihu.com/question/41371402)上找到的解決辦法是卸載,從新安裝:
卸載:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
從新安裝:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
4、換源
咱們須要來修改源(因爲國內被牆),因此腰包源切換至ruby-china在終端執行如下命令,之前使用的大部分命令都是下面的狀況:
sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/ //這個如今是個大坑啊,會報錯:
Error fetching https://ruby.taobao.org/:
Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://ruby.taobao.org/specs.4.8.gz)
這是由於淘寶的鏡像已經再也不維護了,目前是ruby china社區在維護,因此,你能夠執行如下命令來完成換源:
sudo gem update --system
gem sources --remove https://rubygems.org/
gem sources --remove https://ruby.taobao.org/ //已經安裝了淘寶鏡像的須要這一步
gem sources -a https://gems.ruby-china.org/
使用命令 gem sources - l 來驗證你的ruby鏡像是而且僅是ruby-china,若是出現如下文字表名你的命令是成功的:
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
5、安裝cocoapods
執行命令:
$sudo gem install -n/usr/local/bin cocoapods
安裝好以後使用pod,會出現
Setting up CocoaPods master repo
這個就不要急了,你只須要等等吧,這說明cocoapods在將他的信息下載到~/.cocoapods裏,cd 到該目錄裏,用du -sh *命令來查看文件大小
到出現下面的信息,說明你的cocoapods已經安裝完畢,可使用了:
CocoaPods 1.2.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.2.0.beta.1 Setup completed
感受寫的有點亂,將就着看吧,就這樣了,好累啊!