【CocoaPods:Error】Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
この記事からわかること
- CocoaPodsがインストールできないエラーを解決
- エラー:Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
- エラー:Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
- エラー:Could not find 'ffi' (>= 1.15.0) among 85 total gem(s) (Gem::MissingSpecError)
- エラー:You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
index
[open]
\ アプリをリリースしました /
友達や家族の誕生日をメモ!通知も届く-みんなの誕生日-
posted withアプリーチ
発生したエラー
(関係あるか分かりませんが)Mac OSとXcodeをアップデート後にpod init
コマンドを実行しようとしたら以下のようなエラーが発生してPodFileを生成することができなくなってしまいました。
Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
Ignoring ffi-1.15.4 because its extensions are not built. Try: gem pristine ffi --version 1.15.4
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
Ignoring ffi-1.15.4 because its extensions are not built. Try: gem pristine ffi --version 1.15.4
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:128:in `git_version': Failed to extract git version from `git --version` ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun\n") (RuntimeError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:140:in `verify_minimum_git_version!'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:49:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
「Ignoring ffi-1.15.4 because its extensions are not built. Try: gem pristine ffi --version 1.15.4」とは?
発生したエラーを翻訳してみると以下のようになりました。どうやらバージョンアップの兼ね合いなのか拡張機能が正常に動作しなくなってしまったようです。
拡張機能がビルドされていないため、ffi-1.15.5 を無視します。試してください: gem pristine ffi --version 1.15.5
指示通りにgem pristine ffi --version 1.15.5
を実行してみました。
$ gem pristine ffi --version 1.15.4
Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
Ignoring ffi-1.15.4 because its extensions are not built. Try: gem pristine ffi --version 1.15.4
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
PermissionErrorが起きてしまったのでsudo
(スーパーユーザーの権限)で実行します。
$ sudo gem pristine ffi -v '1.15.5'
Password:
Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
Restoring gems to pristine condition...
Building native extensions with: '--enable-libffi-alloc'
This could take a while...
ERROR: While executing gem ... (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
current directory: /Users/s/.gem/ruby/2.6.0/gems/ffi-1.15.5/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 ./siteconf20221208-48155-ilepz9.rb extconf.rb --enable-libffi-alloc
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Users/s/.gem/ruby/2.6.0/gems/ffi-1.15.5 for inspection.
Results logged to /Users/s/.gem/ruby/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.15.5/gem_make.out
なんかめちゃくちゃエラーが出ました。。。ここで再度pod initを実行してみるとエラーが変わってしまいました。
$ pod init
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'ffi' (>= 1.15.0) among 85 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/s/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0', execute `gem env` for more information
解決策を模索していく
まずは一度アンインストールしてみます。ものすごい数削除して良いかを確認されるのでとりあえずyes
を連打してみました。(大丈夫だったかな...)
$ sudo gem uninstall --all
You have requested to uninstall the gem:
activesupport-6.1.6.1
cocoapods-core-1.11.3 depends on activesupport (>= 5.0, < 7)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Successfully uninstalled activesupport-6.1.6.1
You have requested to uninstall the gem:
addressable-2.8.0
cocoapods-1.11.3 depends on addressable (~> 2.8)
cocoapods-core-1.11.3 depends on addressable (~> 2.8)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Successfully uninstalled addressable-2.8.0
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
in addition to the gem? [Yn]
Removing sass
Removing sass-convert
Removing scss
ySuccessfully uninstalled sass-3.7.4
Successfully uninstalled sass-listen-4.0.0
Successfully uninstalled test-unit-3.2.9
Successfully uninstalled typhoeus-1.4.0
Successfully uninstalled tzinfo-2.0.5
Remove executables:
xcodeproj
in addition to the gem? [Yn]
Removing xcodeproj
Successfully uninstalled xcodeproj-1.22.0
Successfully uninstalled xmlrpc-0.3.0
Successfully uninstalled zeitwerk-2.6.0
INFO: Uninstalled all gems in
INFO: Uninstalled all gems in
が出ればアンインストールは成功です。そして再度インストールしてみます。
$ sudo gem install cocoapods
Fetching concurrent-ruby-1.1.10.gem
Fetching i18n-1.12.0.gem
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
Successfully installed httpclient-2.8.3
A new major version is available for Algolia! Please now use the https://rubygems.org/gems/algolia gem to get the latest features.
Successfully installed algoliasearch-1.27.5
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.15.5/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 ./siteconf20221208-49773-78uw9c.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-22/2.6.0/ffi-1.15.5/gem_make.out
また同じエラーが出てgem自体をインストールすることができなくなってしまいました。teratailに同じようなエラーの解決策が載っていたので試してみます。
teratail:cocoapodsインストールのエラー内容が理解できなくて困ってます。
どうやらXcodeCommandLineToolが入っていないことが原因のようなので以下コマンドを実行してXcodeCommandLineToolをインストールしていきます。
$ xcode-select --install
続いて以下のコマンドを実行後再度sudo gem install cocoapods
を実行してみます。
$ sudo gem install ffi
Password:
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Parsing documentation for ffi-1.15.5
Installing ri documentation for ffi-1.15.5
Done installing documentation for ffi after 8 seconds
1 gem installed
$ sudo gem install cocoapods
Fetching concurrent-ruby-1.1.10.gem
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
Successfully installed netrc-0.11.0
34 gems installed
$ pod init
// 生成できた!!!
無事解決することができました。
まだまだ勉強中ですので間違っている点や至らぬ点がありましたら教えていただけると助かります。
ご覧いただきありがとうございました。