Skip to content

Instantly share code, notes, and snippets.

Last active November 7, 2022 16:57
  • Star 31 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Installing ag: the silver searcher on CentOS.

Installing ag on CentOS


  • libpcre
  • liblzma

Download, build and install

$ sudo yum install -y pcre-devel

$ sudo yum install xz-devel

$ cd /usr/local/src

$ sudo git clone

$ cd the_silver_searcher

$ sudo ./

$ sudo make install

$ which ag
Copy link

JasonCC commented Jul 13, 2016

Great! Than you.

Copy link

dcblack commented Sep 1, 2016

autoconf complains "AM_COND_IF not found in library".

configure complains "unexpected token x/$CC on line 4334"

Any ideas?

Copy link

petdance commented Sep 24, 2016

Thanks for posting this.

You should not need to use sudo to clone the repo, or to run ./ or run make.

I would change the last lines to the following, which worked for me.

$ git clone

$ cd the_silver_searcher

$ ./

$ make

$ sudo make install

Copy link

Thank you

Copy link

v6 commented Feb 11, 2017

// , I can confirm that this works on CEntOS 6.7 even without git installed, if one downloads the .zip file of the master branch of the Git repository of the_silver_searcher. I highly recommend using a set of instructions that do not require git.

Copy link

yum install -y the_silver_searcher

Copy link


Copy link

krizex commented Jun 29, 2017


Copy link

u9E9F commented Jul 26, 2017

FYI, make sure you checkout a tag after clone it otherwise the build will probably fail

Copy link

To clarify @kaiserhl's comment:

When I check out current master (9b00f5f) on a Centos 6.7 system and follow the instructions above, I'll get:

config.status: executing depfiles commands
  CC     src/zfile.o
src/zfile.c:57: error: expected specifier-qualifier-list before ‘z_stream’
src/zfile.c: In function ‘zfile_cookie_init’:
src/zfile.c:98: error: ‘union <anonymous>’ has no member named ‘lzma’

To make this work, I did a git checkout 2.0.0 (the latest release tag) before running ./

$ git clone

$ cd the_silver_searcher

$ git checkout 2.0.0

$ ./

$ make

$ sudo make install

Copy link

0xhmn commented Sep 11, 2017

Worked on RHEL 5.3!

Copy link

001101 commented Sep 15, 2017

@allenluce: thanks alot, saved me headache!

Copy link

Note: @manjeetbhatia 's comment is the right answer. No reason to manually build it when it's in the repo.

sudo yum install the_silver_searcher

Copy link

AyushyaChitransh commented Nov 16, 2018

For people who love copy pasting ;) and for me

sudo yum install -y pcre-devel xz-devel
sudo git clone /usr/local/src/the_silver_searcher
cd /usr/local/src/the_silver_searcher
sudo ./
sudo make install
cd -

Copy link

I think this gist came to existence before there was a yum package, for others this works on centos now:
yum install the_silver_searcher

Copy link

HamzGPT commented Jul 17, 2019

Thank you !

Copy link

For some reason my centos finds no package so it was still useful. Somebody should post how to add a repository with yum ;P

Copy link

warb12 commented Nov 20, 2019

I needed zlib dev...

so: sudo yum -y install pcre-devel xz-devel zlib-devel

Copy link

warb12 commented Nov 20, 2019

what repo is the_silver_surfer in for CentOS 8 ?

Copy link

pilot513 commented Dec 6, 2019

I don't found "the_silver_searcher" for RHEL/OEL 8 release
You must build it form src:
[lot@oel8 src]$ cat /etc/os-release | grep '^NAME=' | cut -d'"' -f2 && uname -vrp Oracle Linux Server 4.18.0-147.0.3.el8_1.x86_64 #1 SMP Wed Nov 20 19:11:37 PST 2019 x86_64

git clone && cd the_silver_searcher/ ./ make sudo make install

`[lot@oel8 ~]$ ll /usr/local/bin/ag && LANG=US /usr/local/bin/ag | head -n10
-rwxr-xr-x. 1 root root 319000 дек 6 11:40 /usr/local/bin/ag

Recursively search for PATTERN in PATH.
Like grep or ack, but faster.
ag -i foo /bar/`

Copy link


Copy link

Also... yum provides the_silver_searcher

Copy link

dhull commented Feb 27, 2020

On CentOS 8, you can also build an RPM using the CentOS 7 SRPM. Something like the following worked for me.

curl -O
yum install -y rpm-build xz-devel bash-completion
rpmbuild --rebuild the_silver_searcher-2.1.0-1.el7.src.rpm
sudo yum install $HOME/rpmbuild/RPMS/x86_64/the_silver_searcher-2.1.0-1.el8.x86_64.rpm

Copy link

subchen commented May 9, 2020

Copy link

If you get:

src/zfile.c:63:9: error: unknown type name ‘z_stream’
         z_stream gz;

you have additional dependency missing:

yum install -y zlib-devel

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