2021-02-03關于2021年2月mac第一次安裝cocoapods的問題

macOS:12.2 cocoapods版本:1.10.1 ruby:2.7.0

安裝最新版cocoapods時,pod install時出現下列問題:

/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.0.rc2/lib/active_support/multibyte/unicode.rb:123:in `normalize': undefined method `squish' for #<String:0x00007fe91b0712a8> (NoMethodError)

愿意時需要升級Ruby,系統默認的是2.6.3

嘗試用RVM升級Ruby

http://blog.csdn.net/lissdy/article/details/9191351

如果碰到下面問題

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


1、需要提前安裝homebrew、RVM、Ruby等;步驟可以百度;當安裝rvm時會出現Warning! PATH is not properly set up, /Users/ios-oc/Software/ruby/bin is not at first place. ?的問題是因為輸入了rvm 的操作 ;

下載ruby的時候會提示去一個log文件里查看失敗信息 其中包含cannot load such file -- openssl (LoadError);

這時候需要重新去下載OpenSSL :終端操作:% rvm pkg install openssl? ? 首先需要下載openssl,提示成功后輸入?

rvm reinstall ruby-2.7.0 --with-openssl-dir=$rvm_path/usr

可以選擇自己想要下載的ruby版本 ruby -v 查看版本;

2、這時,輸入pod -v 提示:

Traceback?(most recent call last):

2: from /usr/local/bin/pod:23:in `<main>'

1: from /Library/Ruby/Site/2.6.0/rubygems.rb:300:in `activate_bin_path'

/Library/Ruby/Site/2.6.0/rubygems.rb:281:in `find_spec_for_exe':?can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)

需要輸入:rvm get stable?

最后安裝cocoapods:gem install cocoapods ? 安裝成功。

ps:路徑:/user/ios-oc(本機地址)/.bash_profile;

sudo chmod -R +rx /usr/bin ? ?添加讀寫權限

徹底刪除cocoapods:sudo gem uninstall -n /usr/local/bin cocoapods

顯示隱藏文件命令行:https://blog.csdn.net/qq_32666701/article/details/80607646?

1、期間在.bash_profile文件中 增加了export PATH="/usr/local/opt/ruby/bin:$PATH" ?還有兩行不確定是否添加我全部貼出來了:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

export GEM_HOME=$HOME/Software/ruby

export PATH=PATH:PATH:HOME/Software/ruby/bin

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

export PATH="/usr/local/opt/ruby/bin:$PATH"

2、.bashrc文件如下:


# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

# for brew install

export PATH=/usr/local/bin:$PATH

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

export PATH=/usr/bin/ruby:$PATH

還有最后借鑒:https://www.wddsss.com/main/displayArticle/230下面是內容:

首先需要在 Mac 中安裝 Ruby 環境rvm

1: 安裝rvm 和nvm類似,用于管理Ruby的版本

curl-sSL https://get.rvm.io | bash -s stable

2: 下載成功后設置環境變量

source~/.rvm/scripts/rvmrvm-v //檢查是否設置成功

3: 設置Ruby china鏡像

echo"ruby_url=https://cache.ruby-china.org/pub/ruby"> ~/.rvm/user/db

安裝 Ruby

1: 查詢可安裝版本

rvmlist known

當前最新版本為 2.7.0

2: 開始安裝

rvminstall2.7.0

3: 檢驗安裝

ruby-v

安裝cocoaPods

1: 開始安裝

geminstall cocoapods

2: 檢驗安裝

pod-v

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容