13

I am new to OS X and I am unable to figure out how to install ack. The instructions here didn't help, because the command "install" is failing. Please guide me proper commands.

So far, I have downloaded ack 2.04 and placed it in the /usr/bin folder and then ran perl Makefile.PL successfully. The next command install isn't working for me.

kenorb
  • 155,785
  • 88
  • 678
  • 743
sgowd
  • 946
  • 3
  • 10
  • 27

2 Answers2

27

If you use Homebrew you can simply do:

$ brew install ack

If you are new to OSX I highly recommend this approach because it makes installation of stuff like this MUCH easier. It is a package manager for OSX.

Homebrew link: http://brew.sh/

filype
  • 8,034
  • 10
  • 40
  • 66
user2562923
  • 2,472
  • 1
  • 16
  • 8
4

You can also use the MacPorts installer for OSX:

sudo port install p5.<nn>-app-ack

where <nn> is the version of your Perl installation (Ack is written in Perl). If you don't know the version of Perl you have installed, just type:

perl --version

and you'll know what you need for the port command. The Ack installation page has the information you need for this. More information about MacPorts can be found here.

Searching the web, you'll find LOTS of opinions about Homebrew versus MacPorts. I've used both; they both work (and both fail occasionally - installation of this kind is complex). You'll need to pick one or the other and stick with it as Homebrew doesn't play nicely with MacPorts (or vice versa, depending on your POV). Overriding choice for me is MacPorts as it has many more packages than Homebrew and it puts its stuff in /opt/local to stay out of the way of other programs. YMMV

JESii
  • 4,678
  • 2
  • 39
  • 44
  • Works great. I added `alias ack=ack-5.` in my .zshrc for more convenience – Sébastien Sep 07 '13 at 12:55
  • 1
    Unfortunately, MacPorts doesn't help you by creating a symlink in `/opt/local/bin`. You can add `/opt/local/libexec/perl5.12` to your `PATH`, but that's gross. Alternatives are an alias as @Sebastien suggested, or creating the symlink yourself (`sudo ln -s /opt/local/libexec/perl5.12/ack /opt/local/bin`, or some other place like `~/bin` if that's in your path). The canonical MacPorts way to handle this sort of thing is `port select --set ack some-version-specific-ack`, but there's no app group for ack. – Jim Stewart Nov 15 '13 at 23:23
  • 1
    Note that you can also `port install p5-app-ack`, which is a meta package that will currently get you `p5.12-app-ack`, so at least you don't have to remember the Perl version details. – Jim Stewart Nov 15 '13 at 23:24