Bug 1395079 - Query version of watchman without using daemon; r=mshal
authorGregory Szorc <gps@mozilla.com>
Wed, 30 Aug 2017 10:02:36 -0700
changeset 420511 2e2062e0bc3691e9a85b0925a9055d0d51ca5935
parent 420510 eab0db5216b78b958d71d26d92d1f32adbdaec9c
child 420512 0a8f8b47a1fe7a838aeecb9bed11b8ea09a4764a
push id81
push userfmarier@mozilla.com
push dateTue, 05 Sep 2017 20:09:12 +0000
reviewersmshal
bugs1395079
milestone57.0a1
Bug 1395079 - Query version of watchman without using daemon; r=mshal See inline comment for why. We may want a follow-up configure check for whether watchman is usable (whether we can communicate with the daemon). This can be deferred to another bug. MozReview-Commit-ID: IHfyn7v7vm8
moz.configure
--- a/moz.configure
+++ b/moz.configure
@@ -366,36 +366,32 @@ def tup_progs(build_backends):
 tup = check_prog('TUP', tup_progs)
 
 # watchman detection
 # ==============================================================
 
 option(env='WATCHMAN', nargs=1, help='Path to the watchman program')
 
 @depends('WATCHMAN')
-@imports('json')
 def watchman_info(prog):
     if not prog:
         prog = find_program('watchman')
 
     if not prog:
         return
 
-    out = check_cmd_output(prog, 'version', onerror=lambda: None)
+    # `watchman version` will talk to the Watchman daemon service.
+    # This can hang due to permissions problems. e.g.
+    # https://github.com/facebook/watchman/issues/376. So use
+    # `watchman --version` to prevent a class of failures.
+    out = check_cmd_output(prog, '--version', onerror=lambda: None)
     if out is None:
         return
 
-    # Assume a process not emitting JSON is not watchman or is a
-    # broken watchman.
-    try:
-        res = json.loads(out)
-    except ValueError:
-        return
-
-    return namespace(path=prog, version=Version(res['version']))
+    return namespace(path=prog, version=Version(out.strip()))
 
 @depends_if(watchman_info)
 @checking('for watchman')
 def watchman(w):
     return w.path
 
 @depends_if(watchman_info)
 @checking('for watchman version')