Skip to content

Invalidate projectile-project-root-cache #1936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
raxod502 opened this issue Feb 27, 2025 · 3 comments
Open

Invalidate projectile-project-root-cache #1936

raxod502 opened this issue Feb 27, 2025 · 3 comments

Comments

@raxod502
Copy link
Contributor

raxod502 commented Feb 27, 2025

I find that a frequent operation is:

  • Attempt to projectile-find-file
  • Realize my current directory is not marked as a project
  • Create .projectile file
  • Attempt to projectile-find-file again
  • To my surprise, Projectile still thinks the directory is not marked as a project, even though it is
  • Attempt to use projectile-invalidate-cache
  • To my further surprise, Projectile forces me to select a project to clear the cache for, even though what I need is just to clear projectile-project-root-cache, which is not associated with any project
  • Select an unrelated project to clear the cache for, which clears projectile-project-root-cache as a side effect
  • Now projectile-find-file works

Suggestions for improvement:

  • Detect cases where projectile-project-root-cache should be cleared automatically to avoid user confusion
  • Add a user command for clearing projectile-project-root-cache without needing to select a project
  • Document the fact that this cache exists (since it affects user-visible behavior)

I could help out with this, but creating an issue first for discussion.

@bbatsov
Copy link
Owner

bbatsov commented Feb 27, 2025

All good suggestions. PR welcome!

Btw, does an empty cache get created in this case when there's no project? (this definitely is a bug if so)

@raxod502
Copy link
Contributor Author

The nil return value of the entry in projectile-project-root-functions is cached if no project is detected:

projectile/projectile.el

Lines 1335 to 1340 in 0163b33

;; if we get here, we have failed to find a root by all
;; conventional means, and we assume the failure isn't transient
;; / network related, so cache the failure
(let ((cache-key (format "projectilerootless-%s" dir)))
(puthash cache-key 'none projectile-project-root-cache)
'none)))))

I'm not sure if that is what you meant.

@bbatsov
Copy link
Owner

bbatsov commented Feb 27, 2025

Ah, yeah - I had forgotten about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants