Developing software that relies on Redis is usually a breeze, but I booted my Rails server with `rails s` as usual and noticed Redis wasn't running on my Mac. I use homebrew to manage dependencies which usually just works(tm). I've typed up my process for identifying and fixing the problem.
TL/DR: Make sure your homebrew multi user permissions are set up properly.
That is:
- Create a brew user group (use System Preferences to make it easy)
- Add your users to this group; make sure to login again or open a new term to get the group applied.
sudo chgrp -R brew $(brew --prefix)/*
change homebrew group ownership tobrew
sudo chmod -R g+w+x $(brew --prefix)/*
grant write perms See https://stackoverflow.com/a/58812752 for more details.
Investigation begins
Some context up front: I'm using a multi user homebrew install, both users setup as administrator on MacOS 12.1.
We can use `brew services` to see what's running, so let's do that and check Redis:
% brew services list
Name Status User File
postgresql none
redis none stefan
unbound none
Redis should be running, and its status is "none" which reads to me like it's stopped. Here's the error I got when I tried to ask homebrew to start Redis:
$ brew services start redis
Could not enable service: 125: Domain does not support specified action
Error: Failure while executing; /bin/launchctl enable gui/501/homebrew.mxcl.redis exited with 125.
What didn't work
Reinstalling Redis seemed like an obvious solution as I have no long term data stored that I need to worry about locally for development.
Unfortunately brew reinstall redis
did not clear up the issue; identical error message.
After some research I learned about brew cleanup
which initially looked promising; unfortunately after uninstalling Redis with brew uninstall
followed by brew cleanup
did not appear to do what I wanted:
$ brew services cleanup
All user-space services OK, nothing cleaned...
At this point I'm thinking there is something left over that reinstall and cleanup aren't handling, so I dig into where the file passed to launchctl
is stored: /Users/stefan/Library/LaunchAgents
. Sure enough a leftover homebrew.mxcl.redis.plist
exists, so I delete it.
Almost too excited I brew install redis
and brew services start redis
only to meet disappointment:
$ brew services start redis
Could not enable service: 125: Domain does not support specified action
Error: Failure while executing; /bin/launchctl enable gui/501/homebrew.mxcl.redis exited with 125.
Welp, looks like while homebrew needs to cleanup more files that wasn't the culprit.
Grasping at straws
Lots of similar errors on stackoverflow and others referred to permissions issues; it felt like a stab at the dark, but I logged onto my work user and tried to start Redis:
$ brew services start redis
==> Successfully started redis (label: homebrew.mxcl.redis)
Looks like I somehow didn't try that before, but I shouldn't have gotten my hopes up:
$ brew services info redis
redis (homebrew.mxcl.redis)
Running: ✘
Loaded: ✔
Schedulable: ✘
After searching desperately the next morning I found a two year old issue that is still relevant; in hindsight this should have been the first thing I tried, fixing homebrew multi user permissions:
- Create a brew user group (use System Preferences to make it easy)
- Add your users to this group; make sure to login again or open a new term to get the group applied.
sudo chgrp -R brew $(brew --prefix)/*
change homebrew group ownership tobrew
sudo chmod -R g+w+x $(brew --prefix)/*
grant write perms See https://stackoverflow.com/a/58812752 for more details.
See you next time!