当前位置: 首页 > 工具软件 > rbenv > 使用案例 >

brew, rbenv, rubygems, cocoapods

范豪
2023-12-01

正确的安装顺序:

1. 安装 homebrew (brew.sh)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. 安装 rbenv
 

# 依次执行下面4个命令
brew install rbenv
rbenv init
rbenv install 3.1.2  #选最新版
rbenv global 3.1.2

3. 更新 rubygems

sudo gem update --system

4. 安装 cocoapods

sudo gem install cocoapods

[important]如果不安装新的 ruby 版本,更新 rubygems 或 安装cocoapods 都会失败,因为系统的ruby目录无法写入,所以只能写入自己的 ruby 目录

$ sudo gem install cocoapods
Password:
Fetching json-2.6.1.gem
Fetching minitest-5.15.0.gem
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.

$ gem install cocoapods -n /usr/local/bin
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory. 

 类似资料: