LEBESTS-CENVEN的个人博客
欢迎来到lebests.cn!这里是Cenven的个人博客。
  1. 首页
  2. 开发
  3. 正文

在mac安装cocoapods报错ERROR: Error installing cocoapods:ERROR: Failed to build gem native extension./System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

2020年11月25日 95点热度 2人点赞 0条评论

运行sudo gem install cocoapods时报以下错误:

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

ERROR:  While executing gem ... (Gem::CommandLineError)

    Please specify at least one gem name (e.g. gem build GEMNAME)

mac@macdeMacBook-Air ~ % sudo gem install cocoapods 

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

Building native extensions. This could take a while...

ERROR:  Error installing cocoapods:

ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/ext/ffi_c

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20201125-8473-1dfsz8n.rb extconf.rb

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

checking for ffi.h... *** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options.

Provided configuration options:

--with-opt-dir

--without-opt-dir

--with-opt-include

--without-opt-include=${opt-dir}/include

--with-opt-lib

--without-opt-lib=${opt-dir}/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)

--with-ffi_c-dir

--without-ffi_c-dir

--with-ffi_c-include

--without-ffi_c-include=${ffi_c-dir}/include

--with-ffi_c-lib

--without-ffi_c-lib=${ffi_c-dir}/lib

--enable-system-libffi

--disable-system-libffi

--with-libffi-config

--without-libffi-config

--with-pkg-config

--without-pkg-config

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

You have to install development tools first.

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `block in try_compile'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:534:in `with_werror'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:585:in `try_compile'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1109:in `block in have_header'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in `open'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'

from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1108:in `have_header'

from extconf.rb:10:in `system_libffi_usable?'

from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/mkmf.log

extconf failed, exit code 1

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

Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/gem_make.out

在百般折磨无果后,尝试更新ruby版本:

1、运行rvm list known查看版本

2、安装最新ruby版本rvm install 2.7.0(我这里是2.7.0),将

并export PATH="/usr/local/opt/ruby/bin:$PATH"写入~/.bash_profile或/etc/profile,然后source ~/.bash_profile或source /etc/profile

3、安装完成后执行sudo gem install cocoapods就可以安装cocoapods了!

提示:

如果还安装rvm首先要安装rvm

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

~谢谢打赏~
赏
本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: apple cocoapods gem ios mac ruby rvm
最后更新:2020年11月25日

2279881628@qq.com

打赏 点赞
< 上一篇
下一篇 >

文章评论

取消回复

Cenven

保持饥渴的专注,追求最佳的品质

2021年1月
一 二 三 四 五 六 日
 123
45678910
11121314151617
18192021222324
25262728293031
« 12月    
文章归档
  • 2020年12月
  • 2020年11月
分类目录
  • 开发

COPYRIGHT © 2020 lebests.cn ALL RIGHTS RESERVED.

粤ICP备18064857号-1

粤公网安备 44011702000152号