LoginSignup
0
0

More than 3 years have passed since last update.

Homebrewインストール時、/Library/Developer/CommandLineToolsが存在しなくて、インストールできない場合の回避方法

Posted at

前提

macOS Catalina (10.15.5)
XcodeのCommandLineToolsに依存することがわかっているので、
Xcodeをインストールして、設定から「Command Line Tools」に値が選択されていることを確認済み。

現象

本家のインストールスクリプトを実行してみたが、
/Library/Developer/CommandLineTools関連で、エラーが起こる。
実際、/Library/Developerの下を調べると、CommandLineToolsは存在しなかった。
そして、スクリプトでは、Xcodeをインストールしようとするが、
なぜか、「サーバーから対象ファイルが見つからなかった」のエラーメッセージが表示される。

対策

CommandLineToolsが有効である前提なので、
本家のページで利用するスクリプトをダウンロードし、
Xcodeをインストールする部分を無効にしたら、正常にインストールできて、正常に動作していた。

should_install_command_line_tools()で、Xcodeをインストールするか否かの判断をしていた。

変更は下記の通りにした。

変更前.sh
if version_gt "$macos_version" "10.13"; then
    ! [[ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]]
変更後.sh
if version_gt "$macos_version" "10.13"; then
    return 1

参考資料:
https://discourse.brew.sh/t/xcode-select-error-invalid-developer-directory-library-developer-commandlinetools-failed-during-usr-bin-sudo-usr-bin-xcode-select-switch-library-developer-commandlinetools/693/5

0
0
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
0
0