发布于 4年前

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/json-2.1.0/ext/json/ext/generator

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I         
/Library/Ruby/Site/2.3.0 -r ./siteconf20200121-36371-s533ut.rb extconf.rb

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /usr/local/mysql/bin in PATH, mode 040777

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/json-2.1.0 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/json-2.1.0/gem_make.out

网上查了各种办法都不正确
试了:

sudo gem install cocoapods
sudo gem install -n /usr/local/bin cocoapods

用命令 rvm 命令发现问题如下

-bash: rvm: command not found  

于是重新安装rvm ,安装地址如下
https://rvm.io/rvm/install

Install RVM stable with ruby:

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

安装成功后出现

...............................
ruby-2.6.3 - #installing...........
ruby-2.6.3 - #making binaries executable..
ruby-2.6.3 - #downloading rubygems-3.0.6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
100  866k  100  866k    0     0   291k      0  0:00:02  0:00:02 --:--:--  291k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.3 - #extracting rubygems-3.0.6.....
ruby-2.6.3 - #removing old rubygems........
ruby-2.6.3 - #installing rubygems-3.0.6...............................................
ruby-2.6.3 - #gemset created /Users/hongbao.cui/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/hongbao.cui/.rvm/gemsets/global.gems................................................................
ruby-2.6.3 - #generating global wrappers.......
ruby-2.6.3 - #gemset created /Users/hongbao.cui/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile     /Users/hongbao.cui/.rvm/gemsets/default.gems evaluated to empty gem list
 ruby-2.6.3 - #generating default wrappers.......
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri
Creating alias default for ruby-2.6.3.....

To start using RVM you need to run `source /Users/XXXXXX/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.

其中XXXXXX 为本人的电脑账户

通过

source /Users/XXXXXX/.rvm/scripts/rvm

启动rvm

rvm use ruby-2.0

使用ruby

最后执行安装cocoapods 命令

sudo gem install cocoapods

安装成功

©2020 edoou.com   京ICP备16001874号-3