       (insert "(require 'subr-x)\n")
       (insert "(require 'projectile)\n")
       (insert "(require 'ar-bazel)")
+      (insert (format "(setq default-directory \"%s\")\n" calling-dpath))
+      (insert (format "(ar/bazel--write-rules-cache (ar/bazel-workspace-build-rules t) \"%s\")\n"
+                      (ar/bazel--rules-cache-fpath)))
       (write-file fpath nil))
     fpath))
 

(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)))
                       "*bazel cache*"))

(defun ar/bazel-insert-rule ()

               (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."
