Cocoapods- ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.

升級cocoapods 出現如下錯誤信息

ERROR:  Error installing cocoapods:

ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I /Library/Ruby/Site/2.3.0 -r ./siteconf20200303-68332-1cf9u3w.rb extconf.rb

mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.

Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out

嘗試了升級cocoapods需要一個正確的操作流程和命令以下語句

1、更新gem:sudo gem update --system

2、刪除gem源:gem sources --remove https://ruby.taobao.org/

3、修改gem源:gem sources -a https://gems.ruby-china.org

4、查看gem源是否是最新的:gem sources -l

5、升級cocoapods:sudo gem install -n /usr/local/bin cocoapods

6、查看升級後的cocoapods版本:pod --version

還是沒有成功。

wangpeideMacBook-Pro:~ wangpei$ rvm -v
-bash: rvm: command not found

用命令 rvm 命令發現問題如下:-bash: rvm: command not found

執行 \curl -sSL https://get.rvm.io | bash -s stable --ruby 

wangpeideMacBook-Pro:~ wangpei$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Upgrading the RVM installation in /Users/wangpei/.rvm/
    RVM PATH line found in /Users/wangpei/.mkshrc /Users/wangpei/.profile /Users/wangpei/.bashrc /Users/wangpei/.zshrc.
    RVM sourcing line found in /Users/wangpei/.profile /Users/wangpei/.bash_profile /Users/wangpei/.zlogin.
Upgrade of RVM in /Users/wangpei/.rvm/ is complete.

Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.

👉  Donate: https://opencollective.com/rvm/donate


Ruby enVironment Manager 1.29.9 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

ruby-2.6.3 - #removing src/ruby-2.6.3..
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.

執行 source /Users/XXXXXX/.rvm/scripts/rvm啓動rvm


  * To start using RVM you need to run `source /Users/wangpei/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
wangpeideMacBook-Pro:huobicloud_ios wangpei$ source /Users/wangpei/.rvm/scripts/rvm

rvm use ruby-2.6.3

執行安裝cocoapods 命令sudo gem install cocoapods 或者sudo gem install -n /usr/local/bin cocoapods

ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.com/ - no such name (https://gems.ruby-china.com/specs.4.8.gz)
ERROR:  Possible alternatives: cocoapods
wangpeideMacBook-Pro:~ wangpei$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/
wangpeideMacBook-Pro:~ wangpei$ sudo gem update --system
Latest version already installed. Done.
wangpeideMacBook-Pro:~ wangpei$ sudo gem install -n /usr/local/bin cocoapods
Successfully installed cocoapods-1.9.2
Parsing documentation for cocoapods-1.9.2
Done installing documentation for cocoapods after 1 seconds
1 gem installed
wangpeideMacBook-Pro:~ wangpei$ pod --version
1.9.2

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章