Unable to find ack in Ubuntu 17.10 repositories

I am trying to install ack via apt but it seems it's no longer available in the repos. Both:

sudo apt install ack
sudo apt install ack-grep

give the following error:

E: Package 'ack-grep' has no installation candidate

Is it no longer available in the 17.10 repositories?


Solution 1:

Ack has a test failure in Ubuntu 17.10 Artful and it has been excluded from Ubuntu until it passes. Perl is upgraded on Artful and the old ack version isn't supported by the new Perl. The new version doesn't pass all its tests. The test failure is caused by problems with the testing framework as run under Ubuntu (even when it works fine in Debian.) A new version that passes will be released soon.

In the meantime, a workaround is to install it through CPAN as suggested on the ack homepage. If you don't already have CPAN installed, you need to install it first:

sudo apt install cpanminus

Then you can use it to install ack:

sudo cpanm install App::Ack

It will build and test it, so it take about 2 minutes, but after it is done it will be in your path at /usr/local/bin/ack.

I like this installation option because it uses standard apt and cpan repositories. It uses Perl libraries that will get upgraded by automated tools. It can be easily implemented in automated tools such as Ansible.

Solution 2:

Sadly ack is not in 17.10 repositories. A workaround is to install it manually as per the instructions on its website.

Here's what I did:

$ sudo su
# curl https://beyondgrep.com/ack-2.18-single-file > /usr/local/bin/ack && chmod 0755 /usr/local/bin/ack

Solution 3:

Packages which fail Ubuntu's automatic as-installed package testing are not included in a release, at least those not from the universe archive (which is imported regularily and automated from Debian Unstable).

Due to a change during the Ubuntu 17.10 Artful Release cycle something broke ack's autopkgtest in Ubuntu and hence stopped ack from being included in Ubuntu releases. You can't even find it in the current development snapshot bionic, but you can install it if you add a line for bionic-proposed to your sources.list.

It is still unclear, what exactly that change was, respectively what the reason (maybe a bug in Ubuntu's autopkgtest infrastructure) and what the trigger is. (Maybe the switch to Perl 5.26 exhibited an issue in Ubuntu's autopkgtest infrastructure.)

What is clear though is that this issue is ubuntu-specific since ack's autopkgtest in Debian passes without any issues. And running autopkgtest locally on a development snapshot of Ubuntu 18.04 Bionic doesn't exhibit these test failures either. (And it seems to build on Ubuntu. And the very same test suite is run at build-time, too, and if it didn't pass, the package wouldn't build which is considered a much more severe issue.)

Another hint that the issue is hidden somewhere in Ubuntu's autopkgtest infrastucture is the fact that most test failures regard their input suddenly as STDIN instead of the expected files.

Any hint on the underlying reasons for these strange ubuntu-autopkgtest-specific test failures is very appreciated in either the according launchpad bug report or in the according upstream bug report.

Solution 4:

As @muru indicated in the comments above the package has been removed since it's broken in 17.10, so yes, no ack in the 17.10 repositories for now.

Guess I should keep an eye on https://packages.ubuntu.com/search?suite=artful&keywords=ack to know when it will be available again.

Solution 5:

I was able to install the Ubuntu 18.04 package on my Ubuntu 17.10 box:

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=17.10
DISTRIB_CODENAME=artful
DISTRIB_DESCRIPTION="Ubuntu 17.10"
$ sudo apt install libfile-next-perl
...snip...
$ wget https://launchpad.net/ubuntu/+archive/primary/+files/ack_2.18-2_all.deb
...snip...
$ sudo dpkg -i ack_2.18-2_all.deb
...snip...
$ ack --version
ack 2.18
Running under Perl 5.26.0 at /usr/bin/perl

Copyright 2005-2017 Andy Lester.

This program is free software.  You may modify or distribute it
under the terms of the Artistic License v2.0.

If the dpkg command fails for you, it's probably because you're missing some dependency that I already have. Try to apt install any missing dependencies and then run the dpkg line again.

I like this approach better than using CPAN, because APT/dpkg can still see this package is installed and will be able to upgrade it later once Ubuntu gets their build situation sorted out.

(Thanks Axel Beckert for posting link to the Launchpad bug report, which is where I got this idea.)