DEV Community

Cover image for Install just redis-cli on Ubuntu, Debian, Jessie
Hugo Di Francesco
Hugo Di Francesco

Posted on • Originally published at codewithhugo.com on

Install just redis-cli on Ubuntu, Debian, Jessie

As part of adding integration tests to an app on CircleCI I ran into the following issues:

  • redis-cli's API has changed from version 2 to 3 to 4
    • ie. this works in v4 redis-cli -u ${REDIS_URL} but doesn’t in v2
  • the "only way" to install redis-cli is through a redis-tools or redis-server install and I only need redis-cli not the server or any other tools

What follows is how not to install redis-cli and then how to install redis-cli latest, properly.

This was sent out on the Code with Hugo newsletter last Monday.
Subscribe to get the latest posts right in your inbox (before anyone else).

Bad

apt-get install redis-tools
Enter fullscreen mode Exit fullscreen mode

This installs an outdated version, 2.8.x where stable is 4.x.x.

Better

apt-get install redis-server
Enter fullscreen mode Exit fullscreen mode

Maybe we don’t need the full redis-server install if we only need the CLI.
Sometimes it also installs the old redis-cli… not the best.

Best

cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
cp src/redis-cli /usr/local/bin/
chmod 755 /usr/local/bin/redis-cli
Enter fullscreen mode Exit fullscreen mode

You’ll need libjemalloc1 libjemalloc-dev gcc make most of which should already be installed. We're building from source... which takes about a minute on the CircleCI containers (so I would expect less everywhere else), which is fine.

Credit: DevOps Zone, install redis-cli without installing server. I shamelessly took the snippet from there, because hey, it works.

Installing redis-cli latest on CircleCI

Same as above except:

sudo cp src/redis-cli /usr/local/bin/
sudo chmod 755 /usr/local/bin/redis-cli
Enter fullscreen mode Exit fullscreen mode

CircleCI runs the jobs with a non-root user by default, and kudos to them for that, more tools should make you think about what privileges you have.

I'm not exactly sure what distribution CircleCI images run, some sort of Debian? Let me know at hi@codewithhugo.com, or @hugo__df.

Installing redis-cli latest on Alpine in Docker

apk --upgrade redis
Enter fullscreen mode Exit fullscreen mode

If you know why this works but apt-get install redis-server sometimes installs old redis-cli drop me a line at hi@codewithhugo.com, or Twitter @hugo__df.

This was sent out on the Code with Hugo newsletter last Monday.
Subscribe to get the latest posts right in your inbox (before anyone else).

Nils Stahl

Top comments (0)