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 Redis CLI versions 2 to 3 to 4- ie. this works in v4
redis-cli -u ${REDIS_URL}
but doesn’t in v2
- ie. this works in v4
- the “only way” to install
redis-cli
is through aredis-tools
orredis-server
install and I only need the 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.
Table of Contents
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: install outdated Redis CLI version
apt-get install redis-tools
This installs an outdated version, 2.8.x
where stable is 4.x.x
.
Better: install latest Redis CLI as part of redis-server
apt-get install redis-server
Maybe we don’t need the full redis-server
install if we only need the Redis CLI.
Sometimes it also installs the old redis-cli
… not the best.
Best: install just Redis CLI with redis-cli binary from tarball
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
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
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.
It does however mean that we need an extra command for the Redis CLI to be runnable.
Installing redis-cli latest on Alpine in Docker
apk --upgrade redis
apk
seems to keep a more recent version of Redis CLI in its repositories.
Credit Nils Stahl
Get The Jest Handbook (100 pages)
Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.
orJoin 1000s of developers learning about Enterprise-grade Node.js & JavaScript