lisz-works

プログラミングと興味を貴方に

macOS High Sierraにしたらgitがエラーしたので解決してみた

【スポンサーリンク】

ラップトップを操作する手

macを「macOS High Sierra」にアプデしたら、gitがエラーを吐くようになってしまった……

今回発生した「git: error: unable to find utility "git", not a developer tool or in PATH」の解決方法を書いていきます。

解決方法

解決方法を端的に言うと

XCodeが古かったので入れ直して、ライセンスに同意!

というのが解決方法でした。

gitのエラー

吐いたエラーはコチラ。

y-no-MacBook-Air:~ y$ git
2017-11-18 16:04:56.934 xcodebuild[3177:308809] [MT] DVTAssertions: ASSERTION FAILURE in /SourceCache/DVTFoundation/DVTFoundation-3541/Framework/Classes/Utilities/DVTFoundationUtilities_MRR.m:299
Details:  Assertion failed: [aClass instanceMethodForSelector:observationInfoSEL] != [NSObject instanceMethodForSelector:observationInfoSEL]
Function: __DVTSetupKVODeallocAssertions_block_invoke93
Thread:   <NSThread: 0x7f8414c0c850>{number = 1, name = main}
Hints: None
Backtrace:
  0  0x00000001100130fa -[DVTAssertionHandler handleFailureInFunction:fileName:lineNumber:messageFormat:arguments:] (in DVTFoundation)
  1  0x0000000110012854 _DVTAssertionHandler (in DVTFoundation)
  2  0x0000000110012b54 _DVTAssertionFailureHandler (in DVTFoundation)
  3  0x0000000110012b02 _DVTAssertionFailureHandler (in DVTFoundation)
  4  0x000000011003cc83 __DVTSetupKVODeallocAssertions_block_invoke93 (in DVTFoundation)
  5  0x000000011003d425 __DVTSetupKVODeallocAssertions_block_invoke_2140 (in DVTFoundation)
  6  0x00007fff5c831e88 _dispatch_client_callout (in libdispatch.dylib)
  7  0x00007fff5c84531d _dispatch_queue_barrier_sync_invoke_and_complete (in libdispatch.dylib)
  8  0x000000011003d333 __DVTSetupKVODeallocAssertions_block_invoke135 (in DVTFoundation)
  9  0x00007fff3735fb10 -[__NSObserver _doit:] (in Foundation)
 10  0x00007fff3529ecbc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
 11  0x00007fff3529ebaa _CFXRegistrationPost (in CoreFoundation)
 12  0x00007fff3529e8f2 ___CFXNotificationPost_block_invoke (in CoreFoundation)
 13  0x00007fff3525c6d0 -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
 14  0x00007fff3525b803 _CFXNotificationPost (in CoreFoundation)
 15  0x00007fff3733dbce -[NSBundle loadAndReturnError:] (in Foundation)
 16  0x0000000111a8db0c -[XCPluginManager loadPluginBundle:] (in DevToolsCore)
 17  0x0000000111a8d489 -[XCPluginManager findAndLoadPluginsInDomain:] (in DevToolsCore)
 18  0x0000000111a50f61 XCInitializeCoreIfNeeded (in DevToolsCore)
 19  0x0000000110bbb7c0 +[Xcode3CoreInitializer ide_initializeWithOptions:error:] (in Xcode3Core)
 20  0x00000001106c3847 _IDEInitializeOnePlugInAndPrerequisites (in IDEFoundation)
 21  0x00000001106c2f3a _IDEInitializePlugIns (in IDEFoundation)
 22  0x00000001106c2652 IDEInitialize (in IDEFoundation)
 23  0x0000000110bd3d04 -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
 24  0x000000010ff6a9b0 (in xcodebuild)
 25  0x00007fff5c86b145 start (in libdyld.dylib)
 26  0x0000000000000005
sh: line 1:  3179 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk macosx -find git 2> /dev/null
git: error: unable to find utility "git", not a developer tool or in PATH

なんかめっちゃ出た……

なんだかここが大事そう。

sh: line 1:  3179 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk macosx -find git 2> /dev/null
git: error: unable to find utility "git", not a developer tool or in PATH

ということでググってみた。

XCodeが原因?

参考になりそうなページを見つけました。

Fenrirの別のものに対しての解説だけど、詰まるところ「パス通ってないエラー」の模様。

blog.fenrir-inc.com

というかよくよく見ると、XCodeが原因のよう……なので確認してみると……

XCodeが古いせいで、High Sierraでは未対応のバージョンとなってしまっていたみたいです。

Yosemite(だったと思う)から、一気にアップデートした弊害でしょうか(笑)

XCodeの再インストール

XCodeが対応外のバージョンだったようなので、XCodeをアンインストール→インストール。

XCodeのインストール結構時間かかる……

30分以上かかったか……?(他のことしてたから詳しくはわからない)

改めてgitコマンドを実行

これでターミナルを開いて、改めてgitコマンドを叩いてみた

するとこのような表示に変わった!

Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.

「sudo xcodebuild -license」を叩けと言っているようです。

とりあえず叩く。

y-no-MacBook-Air:~ y$ git


Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.


y-no-MacBook-Air:~ y$ sudo xcodebuild -license
Password:


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

Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'

「さぁて、終わるまで放置だ!」

と思っていたら全然進まない。

よく見ると

「Hit the Enter key to view the license agreements」

要するに「Enter key押してね」と……

押すと

Apple Inc.

Xcode and Apple SDKs Agreement

PLEASE SCROLL DOWN AND READ ALL OF THE FOLLOWING TERMS AND CONDITIONS CAREFULLY BEFORE USING THE APPLE SOFTWARE OR APPLE SERVICES.  THIS IS A LEGAL AGREEMENT BETWEEN YOU AND APPLE.  IF YOU AGREE TO BE BOUND BY ALL OF THE TERMS AND CONDITIONS, CLICK THE “AGREE” BUTTON.  BY CLICKING “AGREE” OR BY DOWNLOADING, USING OR COPYING ANY PART OF THIS APPLE SOFTWARE OR USING ANY PART OF THE APPLE SERVICES, YOU ARE AGREEING ON YOUR OWN BEHALF AND/OR ON BEHALF OF YOUR COMPANY OR ORGANIZATION TO THE TERMS AND CONDITIONS STATED BELOW.  IF YOU DO NOT OR CANNOT AGREE TO THE TERMS OF THIS AGREEMENT, YOU CANNOT USE THIS APPLE SOFTWARE OR THE APPLE SERVICES.  DO NOT DOWNLOAD OR USE THIS APPLE SOFTWARE OR APPLE SERVICES IN THAT CASE.

1.      Definitions
Whenever capitalized in this Agreement:

“Agreement” means this Xcode and Apple SDKs Agreement.

“Apple” means Apple Inc., a California corporation with its principal place of business at One Infinite Loop, Cupertino, California 95014, U.S.A.

“Apple Developer Program License Agreement” means a separate agreement that may be entered into between You and Apple regarding the development and submission of Applications to the App Store for approval and digital signing by Apple, development of libraries for iOS, watchOS, and/or tvOS, and the use of Apple services such as the Apple Push Notification Service, In-App Purchase, and iCloud, among other things.

“Apple Maps Service” means the mapping platform and Map Data provided by Apple via the MapKit API (which is the documented API that enables You to add mapping features or functionality to Applications).  

Software License Agreements Press 'space' for more, or 'q' to quit

スペースキーを押していくと、続きに進んでいきます。

よくよく最初の文を見てみると

「このコマンド叩いてライセンス同意してな」

的な意味くさい。なるほど!

そのまま進みたいときはqを押します。

すると

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コマンドを実行

とりあえずgitコマンド叩いてみた。

y-no-MacBook-Air:~ y$ git
2017-11-20 23:02:57.683 xcodebuild[5984:814645] [MT] PluginLoading: Required plug-in compatibility UUID C3998872-68CC-42C2-847C-B44D96AB2691 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/VVDocumenter-Xcode.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2017-11-20 23:02:57.692 xcodebuild[5984:814645] [MT] PluginLoading: Required plug-in compatibility UUID C3998872-68CC-42C2-847C-B44D96AB2691 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/FuzzyAutocomplete.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2017-11-20 23:02:57.698 xcodebuild[5984:814645] [MT] PluginLoading: Required plug-in compatibility UUID C3998872-68CC-42C2-847C-B44D96AB2691 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/BetterConsole.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2017-11-20 23:02:57.705 xcodebuild[5984:814645] [MT] PluginLoading: Required plug-in compatibility UUID C3998872-68CC-42C2-847C-B44D96AB2691 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

ヘルプ表示が出た!コレはイケてるぞ!

というわけで、SourceTreeでPullしてみると……

できたー!!!

あとがき

WindowsでもOSバージョンによって、動かなくなる……なんてことがありますが……

まさかそういうものだとは思いませんでした(笑)

macはずっと持っているだけで、実mac歴は短いので盲点でしたね(アプデも怠っていたし)。

Windowsと違って、macは普通のアプリをアップデートするかのように、OSアップデートが無料で入ったりするので、この辺の感覚が薄れていました。

ともあれ、困ったらエラーを読む、ググるくらいはしよう!と、怠惰なぼくは改めて思うのでした。