Bug 1395079 - Query version of watchman without using daemon; r?mshal draft
authorGregory Szorc <gps@mozilla.com>
Wed, 30 Aug 2017 10:02:36 -0700
changeset 656031 10b10829c39cf9ed5e74f7f0c3db1b13b704cf1d
parent 655774 ab2d700fda2b4934d24227216972dce9fac19b74
child 728981 9b23b63193f6394761693313abbfc2103ed7270b
push id77034
push usergszorc@mozilla.com
push dateWed, 30 Aug 2017 17:03:04 +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')