1、安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2、安装 rvm
curl -L https://get.rvm.io | bash -s stable
安装 rvm 需要使用 gpg, 因此如果没有 gpg 的需要使用如下命令下载 gpg:
brew install gpg
安装 GPG keys
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
或者按照日志提示去省城对应的key导入到环境变量
3、载入rvm环境(安装日志里面有命令直接粘贴)
* To start using RVM you need to run `source /Users/zhaozhihui/.rvm/scripts/rvm`
4、source 安装环境
source ~/.bash_profile 或者
source ~/.zshrc
5、简单命令
rvm -v 查看版本
rvm list 查看已经安装的列表
rvm list known 查看所有可以安装的版本
rvm install 3.0.0 安装对应版本的ruby
rvm use ext-ruby-2.6.3 --default 设置默认的启用的ruby版本
rvm remove 3.0.0 卸载指定版本的ruby
安装出现问题
参考文章blog.csdn.net/lissdy/arti… 如果碰到下面问题 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.11/x86_64/ruby-2.2.4. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for osx. Installing requirements for osx. Updating system....... Error running 'requirements_osx_brew_update_system ruby-2.2.4',
先运行下面命令,再安装:
rvm autolibs read-only
6、系统自代的ruby导入rvm管理
rvm automount 需要起名和密码
7、rvm 管理引起cocoapods问题卸载重装即可 看标题是换源提高安装速度
sudo gem uninstall cocoapods
gem install cocoapods 新版本 sudo gem install -n /usr/local/bin cocoapods
pod repo list 查看对应的地址列表
8、cocoapods 在1.8版本提出了 cdn 方案 ,然而并不好用,不如直接替换国内镜像
cd ~/.cocoapods/repos
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
pod repo remove truck 移除truck分支
在工程podfile第一行加入 否则truck会在pod insatall 自行下载
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
9、修改完vpn依然访问不到github 修改host文件
查询id地址 找到可以访问github的地址 填写在host文件里需要管理员权限
sudo vim /private/etc/hosts
10、ruby 换源 安装前进行
gem sources -l 查看源列表
gem sources --remove https://rubygems.org/ 删除
gem sources --add https://gems.ruby-china.com/ 添加