1.查询ruby版本
ruby -v
升级Ruby环境,首先需要安装rvm
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
可能会发生错误:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
这一般就是网络问题,配置DNS:8.8.8.8和144.144.144.144我就是这么解决的。
或者
将上面的命令行改成:
curl -sSL https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash
2.查询 rvm版本
rvm -v
3.查询 gem 版本
gem -v
4.查询ruby 镜像
gem sources -l
5.升级ruby环境到 最新
//查询最新版本
rvm list known
//下载对应版本
rvm install ruby 3.0.0
这里很多小伙伴会遇到错误,大部分是因为没有安装Homebrew造成,所以所以所以要提前安装比较好
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
设置为默认版本
rvm use 3.0.0 --default
6.再次查询 看看升级成功
ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
7.查询镜像
gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org/
8.更换镜像地址 成腾讯云 淘宝镜像好像不行了
$ gem sources --remove https://ruby.taobao.org/
https://ruby.taobao.org/ removed from sources
最近发现http://gems.ruby-china.org/ 域名更新了org 换成 com
gem sources -a http://gems.ruby-china.com/
http://gems.ruby-china.com/ added to sources
9.最后升级 cocoaPods
sudo gem install cocoapods
如果成功以后 可以 pod —version 查询一下版本 但是 我自己的电脑 出现了
/Library/Ruby/Site/2.0.0/rubygems.rb:250:in `find_spec_for_exe’: can’t
find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:278:in activate_bin_path
from /usr/local/bin/pod:22:in <main
这个错误
公司的电脑出现了
/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 – utils/popen (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/utils.rb:6:in `<top
(required)>’
这个错误
我就先把 gem 版本升级了
gem update —system
然后查看 gem -v
gem -v
2.6.8
这时候 我从网上看到一位朋友给的解决办法 我就粘贴了试了试 下面是我公司电脑出的错误 , 上面2个错误的解决办法是一样的
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in
to_specs’: Could not find ‘cocoapods’ (>= 0) among 25 total gem(s)
(Gem::LoadError) from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in
to_spec’ from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in
gem’ from /usr/local/bin/pod:22:in <main
现找一下 pod的路径
which pod
/usr/local/bin/pod
删除目录下的文件
sudo rm -rf /usr/local/bin/pod
Password:
获取gem
gem list
*** LOCAL GEMS ***
activesupport (5.0.0.1)
bigdecimal (default: 1.2.6)
bundler-unload(1.0.2)
cocoa (0.1.6)
concurrent-ruby (1.0.2)
executable-hooks (1.3.2)
ffi (1.9.14)
gem-wrappers (1.2.7)
i18n (0.7.0)
io-console (default:0.4.3)
json (default: 1.8.1)
minitest (5.4.3)
pods (0.0.1)
power_assert (0.2.2)
psych (default: 2.0.8)
rake (default: 10.4.2)
rdoc (default: 4.2.0)
rubygems-bundler (1.4.4)
rubygems-update (2.6.8)
rvm (1.11.3.9)
test-unit (3.0.8)
thread_safe (0.3.5)
tzinfo (1.2.2)
移除程序包(我的列表没有,有的话可以删除)
gem uninstall cocoapods -v 0.39.0
gem uninstall cocoapods-core -v 0.39.0
在这里我没有输出 正常的会有输出
Successfully uninstalled cocoapods-0.39.0
Successfully uninstalled cocoapods-core-0.39.0
然后下面我直接安装了cocoapod
sudo gem install cocoapods
然后下面是安装过程
………….Done installing documentation for nanaimo, colored, claide,
CFPropertyList, activesupport, xcodeproj, nap, molinillo,
gh_inspector, fourflusher, escape, cocoapods-try, netrc,
cocoapods-trunk, cocoapods-stats, cocoapods-search, cocoapods-plugins,
cocoapods-downloader, cocoapods-deintegrate, fuzzy_match,
cocoapods-core, cocoapods after 15 seconds 22 gems installed
最后检查一下版本
pod --version
1.9.1
最终完成了
番外:
$ pod --version
执行pod --version
命令 报以下错误
Traceback (most recent call last):
2: from /usr/local/bin/pod:23:in<main>' 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in
activate_bin_path’
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe’: can’t find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
解决方法:
sudo gem uninstall cocoapods
gem install cocoapods
好的,解决问题 布拉布拉布拉布拉~~~