ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
26.18k stars 1.43k forks source link

.ignore file has no affect #1251

Open ksantr opened 6 years ago

ksantr commented 6 years ago

I created a .ignore file in my project and placed there *.js to ignore js files, but I don't see any affect. Ag continues to search in js files. (.ignore is in the same dir where I run ag). The same behaviour with other extensions.

ps Actually, what is right formant for it? cough .js cough* also has no affect

mmartinson commented 6 years ago

The format you're looking for is .*js. Not sure if your question was sarcasm or English is your second language, but "cough *.js cough" is a joke about how typical it is to ignore js files, and probably isn't valid syntax.

The .ignore file , from what I can tell, needs to exist in the directory you're targeting for it to be recognized, not the current directory. If you're searching in .src, the file would need to be there for it to work.

janbaer commented 6 years ago

It's the same for me. I want to search in the current directory and in all subdirectories. But I don't to search in the vendor folder. I created a .ignore file with echo "vendor/" > .ignore. But ag is still searching in the vendor folder. I also tried to use a file mask like vendor/*/. but with the same result. I also tried to exclude .go files completely from the search with adding the file mask to the .ignore folder but it seem the only what will be ignored, is the .ignore file ;-)

janbaer commented 6 years ago

I just realized that I had a really old version (0.31) on my Ubuntu machine and there was also no update for it with apt. But I tried to install it with nix-env and I got the latest version and now the .ignore file will be used. So it works now like it should for me.

thermopyle commented 6 years ago

I have an .ignore in project root where the .git directory is located. There is also a .gitignore in this project root containing an ignore pattern:

Dev/Parts/

In the .ignore file I override this ignore pattern to include the Parts dir in searches:

!Dev/Parts/

The Silver Searcher does not include this directory. I try the same search using ripgrep, then it works. I read somewhere that ag and ripgrep have united their use of .ignore but this does not seem to work in ag.

I do all this from Emacs using Projectile.

gkzsolt commented 5 years ago

@janbaer, what have you used to install the latest version on Ubuntu? I've no idea what nix-env is, and why I should use it on my Ubuntu box. Ubuntu 16.04 sticks with version 0.31.0-2 of silversearcher-ag as "the newest version". But this version does not consider .ignore files, it uses .agignore for that purpose. Also, the manual page man ag describes .agignore as the app file to be ignored, so founding .ignore documented here is very odd and misleading. I don't understand why have developers removed .agignore, if there was a reason for the name change at least it could be left for some time as deprecated and removed in a later version. This is a problem for me because I am using another ag version at home (with Ubuntu 18.04), but cannot upgrade it at the office, and the 2 ag-s are not compatible. How can I install the newest ag version on Ubuntu 16.04?

janbaer commented 5 years ago

@gkzsolt Since some packages on the original Ubuntu-Package are really old it's possible to add additional channels to APT or use for some packages another package manager. I use for some apps like Ranger and the_silver_searcher the package manager which comes originally with NixOS (https://nixos.org/nix/manual/) but can also be installed separately on any other Linux distro. And the most packages there are more up to date than for APT.