美文网首页
记一次M1 Mac pod更新问题。

记一次M1 Mac pod更新问题。

作者: 雾霾下的天空 | 来源:发表于2024-01-29 10:35 被阅读0次

pod install 报错

LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): tried: '/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle' (no such file), '/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')) - /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle

参考stackoverflow的回答

Answering my own question. I fixed the ffi issue by uninstalling my faulty Ruby version and CocoaPods, then I used the -x86_64 arch to reinstall ffi and CocoaPods.

These are the steps I did to get back to a working state (and to apply the M1 workarounds for ffi):

Uninstall Ruby with: brew uninstall ruby --force
Uninstall CocoaPods. At first, try to list all CocoaPods versions / components with gem list --local | grep cocoapods. Then uninstall them one by one, in my case:
sudo gem uninstall cocoapods

sudo gem uninstall cocoapods-core

sudo gem uninstall cocoapods-downloader

etc.

As a next step I was able to reinstall ffi and then CocoaPods with:
sudo arch -x86_64 gem install ffi

sudo arch -x86_64 gem install cocoapods

Once done, I could run pod install as expected. Note that I had the Terminal open all the time in standard mode - no Rosetta required.

执行 sudo arch -x86_64 gem install ffi --verbose失败
需要更新gem
sudo gem update --system --verbose

又报错ruby版本过低

ERROR:  Error installing rubygems-update:
    There are no versions of rubygems-update (= 3.5.5) compatible with your Ruby & RubyGems
    rubygems-update requires Ruby version >= 3.0.0. The current ruby version is 2.6.10.210.
ERROR:  While executing gem ... (NoMethodError)

更新ruby

brew install ruby --verbose

配置环境

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
source ~/.zshrc 

相关文章

网友评论

      本文标题:记一次M1 Mac pod更新问题。

      本文链接:https://www.haomeiwen.com/subject/gypgodtx.html