How can I install and use ack library on Windows?

WindowsPerlAck

Windows Problem Overview


I have never used Perl, but I am really impressed by the ack, which I would like to use for source code searching, etc.

Can anyone guide me of how to make use of this excellent library on Windows?

Windows Solutions


Solution 1 - Windows

Start by installing perl http://strawberryperl.com/

Install App::Ack by typing (in a windows command shell)

C:\>cpan App::Ack

And undoubtedly this will prove useful http://learn.perl.org/

Solution 2 - Windows

Not all the tests pass on all versions of Windows. You can most likely get 100% functionality from ack even if the install tests fail. Here is the command to force installation if failing tests prevent a normal install:

perl -MCPAN -e "CPAN::Shell->force(qw(install App::Ack));"

Solution 3 - Windows

If you already have msysgit installed, then you don't need to install Perl, because you already have a version. You just need to download the standalone version of ack and put it somewhere in your bash path1. You can then run ack from your msysgit bash prompt.

If you also want to be able to run ack from the Windows command prompt, then you will need to create a batch script somewhere in your Windows path2 with the contents:

@"C:\Program Files\Git\bin\perl" C:\path\to\ack-standalone.pl %*

(You'll obviously need to edit the paths above to match your msysgit installation and where you placed the ack script.)

1: I just stuck mine in the mysysgit bin directory: C:\Program Files\Git\bin\ack. This isn't the most sensible location for it, but it works.
2: Again, I just created the file ack.bat in the msysgit bin directory C:\Program File\Git\bin.

Solution 4 - Windows

If you have cygwin installed, you can simply download the standalone version. Perl is installed with cygwin. Here are the steps:

$ vim .bash_profile

Remove the comments from the lines:

# if [ -d "${HOME}/bin" ] ; then
#  PATH="${HOME}/bin:${PATH}"
# fi

Load the changes:

$ source .bash_profile

Make a bin directory:

$ mkdir ~/bin

Download ack (from the homepage):

$ curl https://beyondgrep.com/ack-2.22-single-file > ~/bin/ack && chmod 0755 ~/bin/ack

Note: you will have to manually install curl as it doesn't come with cygwin by default.

Solution 5 - Windows

You should also run the following command to enable color highlights: cpan Win32::Console::ANSI

Solution 6 - Windows

I had to force cpan to install App::Ack since some of the tests didn't pass:

C:\> cpan
cpan> force install App::Ack
cpan> q

Solution 7 - Windows

Nothing worked for me, until I went to the ack website and saw this.

enter image description here

And I ran the following command in cmd prompt:

choco install ack

Solution 8 - Windows

Depending on how you feel about installing pre-built binaries from open source projects, you might also consider The Silver Searcher (ag). It's ack-compatible and faster than ack. It's also available on Linux from the repositories in recent distros.

http://blog.kowalczyk.info/software/the-silver-searcher-for-windows.html

Solution 9 - Windows

You can install ack via cpan:

install strawberry perl

run cmd as admin

install ack:

cpan> force install App::Ack

it should work from there, followed this guide: http://www.jeedo.net/how-to-install-ack-on-windows-10/

Worked without any hitches.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionrajesh pillaiView Question on Stackoverflow
Solution 1 - WindowsNifleView Answer on Stackoverflow
Solution 2 - WindowsRobert WahlerView Answer on Stackoverflow
Solution 3 - WindowsRichView Answer on Stackoverflow
Solution 4 - WindowsSwooganView Answer on Stackoverflow
Solution 5 - WindowsJayView Answer on Stackoverflow
Solution 6 - WindowsTomView Answer on Stackoverflow
Solution 7 - Windowsh-raiView Answer on Stackoverflow
Solution 8 - WindowsJim HunzikerView Answer on Stackoverflow
Solution 9 - WindowsnetsmithView Answer on Stackoverflow