 (defun ar/bazel-cache-build-rules ()
   (interactive)
   (async-shell-command (concat (expand-file-name invocation-name invocation-directory)
-                               " --batch -Q"
-                               " -l " (ar/bazel--init-fpath)
-                               (format " --execute '(ar/bazel--write-rules-cache (ar/bazel-workspace-build-rules t) \"%s\")'"
-                                       (ar/bazel--rules-cache-fpath)))
+                               " --batch -Q -l " (ar/bazel--write-rules-cache-async-path))
                        "*bazel cache*"))
 
 (defun ar/bazel-insert-rule ()

  (concat (file-name-as-directory (ar/bazel-workspace-path))
          ".bazelrules"))

(defun ar/bazel--init-fpath ()
  (let ((fpath (concat (temporary-file-directory)
                       "bazel-init.el")))
    (with-current-buffer (find-file-noselect fpath)
      (delete-region (point-min) (point-max))
      (insert "(setq load-path '(\n")
      (mapc (lambda (path)

               (t
                (list (ar/bazel-workspace-path))))))
    (message "Searching %s" dirs)
    (mapcar (lambda (path)
              (expand-file-name path))
            (apply 'process-lines (nconc (list "find")
                                         dirs
                                         (list "-name" "BUILD"))))))

(defun ar/bazel-workspace-build-rules (&optional fresh-read)
  "Get all workspace qualified rules."
