MacのVSコードターミナルで You have not agreed to the Xcode license agreements ... のメッセージが表示されたときの対処法

初めに

  • 学習中に遭遇したトラブルについてシェアをしていきます。

git versionを行った時にYou have not agreed to the Xcode license agreements ...のエラー

  • 原因として考えられるのは久しぶりにVSコードを開いてgitを使用としたから?

  • 以前はgitを利用していたのに不思議なエラー・・

エラー内容

You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.

解決方法

主に下のサイトを参考にしています。

qiita.com

  • 上記の記事を参考にエラー内容を把握するとライセンスの同意が必要なことがわかる。

  • sudo xcodebuild -licenseを入力後パスワードを入力。

  • 同じようなメッセージが出力されている場合は再度繰り返す。

  • すると以下のようなメッセージが出てくる

By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]
  • agreeを入力しenterを押す。

  • 今まで通りにgit versionを利用できる。

まとめ

  • 今回のエラーはライセンスの取得に関するエラー

  • 基本的にはメッセージに従えば良いが、何度か同じことを繰り返すことがある。最後にagreeを入力させるメッセージまで移動すれば良い。