Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing ag: the silver searcher on CentOS.

Installing ag on CentOS

Prerequistes

  • libpcre
  • liblzma

Download, build and install

$ sudo yum install -y pcre-devel

$ sudo yum install xz-devel

$ cd /usr/local/src

$ sudo git clone https://github.com/ggreer/the_silver_searcher.git

$ cd the_silver_searcher

$ sudo ./build.sh

$ sudo make install

$ which ag
/usr/local/bin/ag
@dideler

This comment has been minimized.

Copy link

@dideler dideler commented May 5, 2015

Worked great, thanks!

@vincepii

This comment has been minimized.

Copy link

@vincepii vincepii commented Jun 2, 2015

Many thanks!

A small note:

$ sudo ./build.sh
./build.sh: line 16: aclocal: command not found

Install automake if aclocal is not there

sudo yum install automake
@kdorff

This comment has been minimized.

Copy link

@kdorff kdorff commented Feb 4, 2016

Thank you. Worked like a charm.

@TheJavaGuy

This comment has been minimized.

Copy link

@TheJavaGuy TheJavaGuy commented Jun 24, 2016

Thank you!

@JasonCC

This comment has been minimized.

Copy link

@JasonCC JasonCC commented Jul 13, 2016

Great! Than you.

@dcblack

This comment has been minimized.

Copy link

@dcblack 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?

@petdance

This comment has been minimized.

Copy link

@petdance petdance commented Sep 24, 2016

Thanks for posting this.

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

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


$ git clone https://github.com/ggreer/the_silver_searcher.git

$ cd the_silver_searcher

$ ./build.sh

$ make

$ sudo make install
@grillermo

This comment has been minimized.

Copy link

@grillermo grillermo commented Dec 1, 2016

Thank you

@v6

This comment has been minimized.

Copy link

@v6 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.

@manjeetbhatia

This comment has been minimized.

Copy link

@manjeetbhatia manjeetbhatia commented May 11, 2017

yum install -y the_silver_searcher

@fkotsian

This comment has been minimized.

Copy link

@fkotsian fkotsian commented May 30, 2017

Thanks!

@krizex

This comment has been minimized.

Copy link

@krizex krizex commented Jun 29, 2017

Thanks!!!

@u9E9F

This comment has been minimized.

Copy link

@u9E9F u9E9F commented Jul 26, 2017

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

@allenluce

This comment has been minimized.

Copy link

@allenluce allenluce commented Aug 9, 2017

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 ./build.sh:

$ git clone https://github.com/ggreer/the_silver_searcher.git

$ cd the_silver_searcher

$ git checkout 2.0.0

$ ./build.sh

$ make

$ sudo make install
@yar00001

This comment has been minimized.

Copy link

@yar00001 yar00001 commented Sep 11, 2017

Worked on RHEL 5.3!

@001101

This comment has been minimized.

Copy link

@001101 001101 commented Sep 15, 2017

@allenluce: thanks alot, saved me headache!

@tuckerww

This comment has been minimized.

Copy link

@tuckerww tuckerww commented May 11, 2018

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

@AyushyaChitransh

This comment has been minimized.

Copy link

@AyushyaChitransh 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 https://github.com/ggreer/the_silver_searcher.git /usr/local/src/the_silver_searcher
cd /usr/local/src/the_silver_searcher
sudo ./build.sh
sudo make install
cd -
@stkrzysiak

This comment has been minimized.

Copy link

@stkrzysiak stkrzysiak commented Nov 17, 2018

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

@stalamuerte

This comment has been minimized.

Copy link

@stalamuerte stalamuerte commented Jul 17, 2019

Thank you !

@beppe9000

This comment has been minimized.

Copy link

@beppe9000 beppe9000 commented Sep 9, 2019

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

@warb12

This comment has been minimized.

Copy link

@warb12 warb12 commented Nov 20, 2019

I needed zlib dev...

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

@warb12

This comment has been minimized.

Copy link

@warb12 warb12 commented Nov 20, 2019

what repo is the_silver_surfer in for CentOS 8 ?

@pilot513

This comment has been minimized.

Copy link

@pilot513 pilot513 commented Dec 6, 2019

@warb12
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 https://github.com/ggreer/the_silver_searcher.git && cd the_silver_searcher/ ./build.sh make sudo make install

Then:
`[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

Usage: ag [FILE-TYPE] [OPTIONS] PATTERN [PATH]
Recursively search for PATTERN in PATH.
Like grep or ack, but faster.
Example:
ag -i foo /bar/`

@andersonreinkordt

This comment has been minimized.

Copy link

@andersonreinkordt andersonreinkordt commented Dec 23, 2019

HUZZZAH!

@beppe9000

This comment has been minimized.

Copy link

@beppe9000 beppe9000 commented Dec 23, 2019

Also... yum provides the_silver_searcher

@dhull

This comment has been minimized.

Copy link

@dhull 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 https://download-ib01.fedoraproject.org/pub/epel/7/SRPMS/Packages/t/the_silver_searcher-2.1.0-1.el7.src.rpm
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
@subchen

This comment has been minimized.

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