LoginSignup
6
6

More than 3 years have passed since last update.

Warning: Xcode alone is not sufficient on Mojave.とかxcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)となったときの対応方法

Last updated at Posted at 2019-06-18

事象 : xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)

  • 環境
    • macOS Big Sur バージョン11.1
    • Homebrew 2.7.1
% brew update
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/cask-fonts).
#...省略...

原因 : OSのアップデートでXCodeのCommandLineTools/usrディレクトリのbinディレクトリが紛失したから?

ぐぐってみるていくつかのサイトを見るとOSのアップデート後にちょくちょくあるらしい。

# おぉ、エラーメッセージにあるbinディレクトリがない!
% ls -la /Library/Developer/CommandLineTools/usr
total 0
drwxr-xr-x  3 root  wheel  96 12 16 19:42 .
drwxr-xr-x  3 root  wheel  96 12 16 19:42 ..
drwxr-xr-x  3 root  wheel  96 12 16 19:42 share

対応 : xcode-selectをインストールする

  1. xcode-selectをインストールする
  2. コマンドで表示されたダイアログに従ってインストールする
    • スクリーンショット 2020-12-29 20.57.57.pngスクリーンショット 2020-12-29 20.58.47.pngスクリーンショット 2020-12-29 20.59.01.pngスクリーンショット 2020-12-29 21.05.59.png
  3. エラーが消えたか確認する
# xcode-selectをダイアログに従ってインストールする
% xcode-select --install
xcode-select: note: install requested for command line developer tools

# エラーが消えたか確認する
% brew update
Updated 1 tap (homebrew/core).
No changes to formulae.

事象 : Warning: Xcode alone is not sufficient on Mojave.

  • 環境
    • macOS Mojave バージョン10.14.5
    • Homebrew 2.1.6
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Warning: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
  xcode-select --install

原因 : Xcode.appを削除したから

そもそもXcode.appを削除したことがことの始まりだったのだろう・・・。
MacにおいてXcodeは大切なものだったらしい・・・諦めてインストールする。

対応 : xcode-selectをインストールする

  1. Command Line Toolsをインストールする
    1. Appleのサイトからdmgファイルをダウンロードするスクリーンショット 2019-06-19 0.35.40.pngスクリーンショット 2019-06-19 0.37.39.png
    2. pkgをクリックしてダイアログに沿ってインストールするスクリーンショット 2019-06-19 0.39.03.pngスクリーンショット 2019-06-19 0.39.17.png
  2. xcode-selectをインストールする
    1. コマンドで表示されたダイアログにそって進めてインストールするスクリーンショット 2019-06-19 0.23.53.pngスクリーンショット 2019-06-19 0.24.09.pngスクリーンショット 2019-06-19 0.25.30.png
  3. Warningが消えたか確認する
# xcode-selectをインストールする
$ xcode-select --install
xcode-select: note: install requested for command line developer tools

# Warningが消えたか確認する
$ brew update
Already up-to-date.
$ brew doctor
Your system is ready to brew.

失敗した対応 : Xcodeは使わないからアンイストールする

# /Library/Preferences/配下
$ find /Library/Preferences/ -type f | grep -i xcode
/Library/Preferences//com.apple.dt.Xcode.plist
$ find /Library/Preferences/ -type f | grep -i xcode | sudo xargs rm
$ find /Library/Preferences/ -type f | grep -i xcode
$

# ~/Library/Preferences/配下
$ find Library/Preferences/ -type f | grep -i xcode
Library/Preferences//com.apple.dt.xcodebuild.plist
Library/Preferences//com.apple.dt.Xcode.plist
Library/Preferences//com.apple.preferences.extensions.XcodeSourceEditor.plist
Library/Preferences//com.apple.preferences.extensions.XcodeSourceControlHost.plist
$ find Library/Preferences/ -type f | grep -i xcode | xargs rm
$ find Library/Preferences/ -type f | grep -i xcode
$ 

# ~/Library/Caches/com.apple.dt.Xcode/配下
$ find Library/Caches/ -type f | grep -i xcode
Library/Caches//com.apple.dt.Xcode/fsCachedData/70D9F1CB-B3B7-4605-AD98-4C911D694D14
Library/Caches//com.apple.dt.Xcode/Cache.db-shm
Library/Caches//com.apple.dt.Xcode/Cache.db-wal
Library/Caches//com.apple.dt.Xcode/Cache.db
$ find Library/Caches/ -type d | grep -i xcode | xargs rm -rf
$ find Library/Caches/ -type f | grep -i xcode
$

# ~/Library/Application Support/com.apple.sharedfilelist/配下
$ find Library/Application\ Support/com.apple.sharedfilelist/ -type f | grep -i xcode | sed -e 's/ /\\ /g'
Library/Application\ Support/com.apple.sharedfilelist//com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.dt.xcode.sfl
Library/Application\ Support/com.apple.sharedfilelist//com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.dt.xcode.sfl2
$ find Library/Application\ Support/com.apple.sharedfilelist/ -type f | grep -i xcode | sed -e 's/ /\\ /g' | xargs rm
$ find Library/Application\ Support/com.apple.sharedfilelist/ -type f | grep -i xcode
$ 

# ~/Library/Application Support/Xcodeディレクトリ
$ find Library/Application\ Support/ -maxdepth 1 -type d | grep -i xcode
Library/Application Support//Xcode
$ find Library/Application\ Support/ -maxdepth 1 -type d | grep -i xcode | sed -e 's/ /\\ /g' | xargs rm -rf
$ find Library/Application\ Support/ -maxdepth 1 -type d | grep -i xcode
$ 

# ~/Library/Developer/Xcodeディレクトリ
$ find Library/Developer/ -maxdepth 1 -type d | grep -i xcode
Library/Developer//Xcode
$ find Library/Developer/ -maxdepth 1 -type d | grep -i xcode | sed -e 's/ /\\ /g' | xargs rm -rf
$ find Library/Developer/ -maxdepth 1 -type d | grep -i xcode

# ~/Library/Developer/CoreSimulator/配下にはなかった
$ find Library/Developer/CoreSimulator/ -type f | grep -i xcode
$

# 今一度doctorする
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don`t worry or file an issue; just ignore this. Thanks!

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Warning: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
  xcode-select --install

# がーーん、だめだった・・・じゃ、update・・・で悪化していることに気がついた
$ brew update
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
# 省略
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6