Projectile will ignore the file when projectile-enable-caching is set to t.
Projectile dose not ignore the file when projectile-enable-caching is set to t after open a ignored file directly in project.
Minimal test config
(setq package-archives '(("marmalade" . "http://marmalade-repo.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(package-initialize)
(setq package-enable-at-startup nil)
(unless (and (file-exists-p (expand-file-name "elpa/archives/marmalade" user-emacs-directory))
(file-exists-p (expand-file-name "elpa/archives/gnu" user-emacs-directory))
(file-exists-p (expand-file-name "elpa/archives/melpa" user-emacs-directory))
(file-exists-p (expand-file-name "elpa/archives/org" user-emacs-directory)))
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(setq use-package-verbose t
use-package-enable-imenu-support t)
(require 'use-package)
(use-package projectile
:ensure t
:diminish projectile-mode
:commands (projectile-global-mode)
:init (setq projectile-enable-caching t)
:config (projectile-global-mode 1))
Run the setup config
mkdir /tmp/project
cd /tmp/project
git init .
mkdir ignore
touch ignore/i
touch ignore/j
touch ignore/k
touch a
touch b
touch c
echo "ignore" >> .gitignore
git add .
git commit -m "first commit"
Run
(progn
(find-file "/tmp/project/a")
(projectile-find-file))
then C-g and run
(progn
(find-file "/tmp/project/a")
(find-file "/tmp/project/j")
(projectile-find-file))
to see the difference, and will get a message File j added to project /private/tmp/project/ cache.
Projectile 20161008.47
GNU Emacs 25.1.1 (x86_64-apple-darwin16.0.0, Carbon Version 157 AppKit 1504) of 2016-09-21
_macOS 10.12_
I am experiencing this painful issue on Windows. It's very slow if disabling cache.
I think it's a bug. All files in .gitignore and .ignore should not be cached in a git project, in my opinion.
Can anyone fix this defect?
I'm experiencing this bug as well. I was wondering why ignored files were being added to the cache. After a quick look at the code, it looks like only ignores in .projectile are considered in this case.
Adding to the confusion: Clearing the cache (e.g. projectile-find-file with prefix arg) will get rid of those files until they are opened again.
.gitignore can work well in master version.My Mac version is macOS 10.13.1.check again? confirm projectile version is up to date.
I can still reproduce this bug on Projectile version 20180118.745 from Melpa.
Let me add something here. It is very annoying when projectile doesn't ignore git-ignored files while doing projectile-grep. But for me projectile-find-file works as expected on latest and previous versions.
@jsirex So, I am using projectile-ag and rg-projectile instead.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!
.gitignore not worked in windows , use .projectile instead .
but .gitignore work well on macos and linux
facing this on mac. projectile-find-file works fine, but projectile-grep includes ignored files, flooding the results buffer.
Is there any news on this one? Extremely frustrating on Windows :(
Okay, I have found a workaround for windows.
You have to have Msys64 or any other "posix userspace" installed.
(setenv "PATH" (concat "C:\\msys64\\usr\\bin;" (getenv "PATH")))
...
(use-package projectile
:ensure t
:custom
(projectile-indexing-method 'alien)
...)
Any updates on this issue? it is getting very frustrating
Same here: problem under windows. Invalidating cache does not help.
I suspect a lot of these issues will be resolved by setting projectile-indexing-method (as nvkv showed) -- if set to native (default on windows), it is very slow and also ignores .gitignore; if set to alien it follows .gitignore & ignores .projectile. If set to hybrid it pays attention to both .gitignore & .projectile
I suspect a lot of these issues will be resolved by setting
projectile-indexing-method(as nvkv showed) -- if set tonative(default on windows), it is very slow and also ignores .gitignore; if set toalienit follows .gitignore & ignores .projectile. If set tohybridit pays attention to both .gitignore & .projectile
I am on manjaro linux and changing those had no consequence for me. Anyway, the workaround above of using ag / rg works for me, they follow my .gitignore.
Btw, the native indexing was made quite a bit faster a few months ago.
As for the rest - check out https://docs.projectile.mx/projectile/configuration.html#project-indexing-method
Basically, Projectile doesn't know anything about .gitignore, but if you're using hybrid/alien indexing the tool that Projectile will shell out to might know about .gitignore (e.g. by default it defers to git ls-files).
Also - on Windows I think it's best to run Emacs in WSL as described here https://emacsredux.com/blog/2020/09/23/using-emacs-on-windows-with-wsl2/
Most helpful comment
I suspect a lot of these issues will be resolved by setting
projectile-indexing-method(as nvkv showed) -- if set tonative(default on windows), it is very slow and also ignores .gitignore; if set toalienit follows .gitignore & ignores .projectile. If set tohybridit pays attention to both .gitignore & .projectile