Running services from different users


(Jed Hassell) #1

I am installing a formula which installs a plist to be used with brew services. My user is a user with admin rights. I would like to be able to start this service from a user without admin rights. Currently, when I run brew services start formula, I get this error:

/bin/launchctl enable gui/503/homebrew.mxcl.formula
Usage: launchctl enable <service-target>
Error: Failure while executing: /bin/launchctl enable gui/503/homebrew.mxcl.formula

If I use sudo it works but the intent is to be able to use it on a user without sudo rights.


(Nouguier Olivier) #2

I encounter the same issue when “brew” user is not logged in.


(Eduard Rozenberg) #3

The user who ran brew to install formulas owns the files under /usr/local, and a different user doesn’t have permission to make changes.

You don’t mention which formula. If it was say mariadb, you could change ownership of /usr/local/var/mysql/ directory and contents to be owned by that regular user.

Try running the command that appears in gui/503/homebrew.mxcl.formula manually, to see if the error is starting the service, or error comes from launchctl not able to copy the plist where it wants.


(Nouguier Olivier) #4

Sorry for the late reply.
(was mongodb).