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-20260820.1509/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))
  ;; Drop the file-existence cache too - otherwise, after the user
  ;; creates a project marker (`.projectile', `.git', etc.) over TRAMP,
  ;; the negative entries cached during earlier root-walks would keep
  ;; reporting "not found" for up to `projectile-file-exists-remote-cache-expire'
  ;; seconds even though the project root walk has been invalidated.
  (clrhash projectile-file-exists-cache)
  (when-let* ((project-root
              (if prompt
                  (completing-read "Remove cache for: "
                                   (hash-table-keys projectile-projects-cache))
                (projectile-project-root))))
    (projectile--invalidate-project-cache project-root)
    (projectile--message "Invalidated cache for %s"
                         (propertize project-root 'face 'font-lock-keyword-face)))
  (when (fboundp 'recentf-cleanup)
    (recentf-cleanup)))