Function: projectile-invalidate-cache

projectile-invalidate-cache is an autoloaded, interactive and byte-compiled function defined in projectile.el.

Signature

(projectile-invalidate-cache PROMPT)

Documentation

Remove the current project's files from projectile-projects-cache.

With a prefix argument PROMPT prompts for the name of the project whose cache to invalidate.

The global (project-independent) cache for checking which project a file belongs to, is also cleared. Therefore this function is still useful even when not operating on a specific project, and as such only the global cache is cleared when there is no current project (unless you give a prefix argument).

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
;;;###autoload
(defun projectile-invalidate-cache (prompt)
  "Remove the current project's files from `projectile-projects-cache'.

With a prefix argument PROMPT prompts for the name of the project whose cache
to invalidate.

The global (project-independent) cache for checking which project a file
belongs to, is also cleared. Therefore this function is still useful even
when not operating on a specific project, and as such only the global cache
is cleared when there is no current project (unless you give a prefix
argument)."
  (interactive "P")
  (setq projectile-project-root-cache (make-hash-table :test 'equal))
  (when-let* ((project-root
              (if prompt
                  (completing-read "Remove cache for: "
                                   (hash-table-keys projectile-projects-cache))
                (projectile-project-root))))
    ;; reset the in-memory cache
    (remhash project-root projectile-project-type-cache)
    (remhash project-root projectile-projects-cache)
    (remhash project-root projectile-projects-cache-time)
    (remhash project-root projectile--dirconfig-cache)
    ;; reset the project's cache file
    (when (projectile-persistent-cache-p)
      ;; TODO: Perhaps it's better to delete the cache file in such cases?
      (projectile-serialize nil (projectile-project-cache-file project-root)))
    (when projectile-verbose
      (message "Invalidated Projectile cache for %s."
               (propertize project-root 'face 'font-lock-keyword-face))))
  (when (fboundp 'recentf-cleanup)
    (recentf-cleanup)))