-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sudo brew services
on Linux broken (me too)
#724
Comments
That was the
Yes. When you run |
As I stated above, it seems a little difficult to get brew to work under sudo, because it clears environment variables that brew wants to use and resets a to a sanitized system-only PATH. I'm sure there are ways to get sudo to work but I didn't go there (yet). So as I showed above, I just set up root's dot files so that I could run a root login shell via I just want
|
To answer your question about command output from brew commands (as root but without sudo):
|
This seems to be a Linux-distro specific thing. Many people have used Homebrew on macOS (and some forms of Linux) for a long time without these issues. I suspect it's because your distro/
These are the commands whose output I need to know. Running as The issue is titled |
You asked what $HOME was when running sudo:
I'm honestly not trying to be difficult here but I can rename the issue if it helps. I'm not sure what the difference is between supporting a command running under sudo with a proper environment and directly under a root shell with a proper environment. Either way, it's root and it has an environment set; it should effectively be the same thing. That said, here's some more about the sudo issue: Per the sudoers(5) man page:
And also:
My PATH is not being inherited, which makes sense given the stated defaults above, and also that both of those seem to be explicitly set in the default Ubuntu /etc/sudoers file. So that is why just plain Can you recommend a sudoers entry for running But back to my real problem: Because brew not being in the sudo secure_path seems to be the sticking point here, maybe we can get past that if I tell you that if I run sudo with the full path to brew specified it still gives exactly the same error:
|
Yup, this is your problem: your Something like |
Ok, that did in fact fix it, thank you. But why? What is it using $HOME for when I thought all brew stuff was relative to $HOMEBREW_PREFIX ? For future reference, I made a sudoers entry
That does allow |
Homebrew's cache is stored in your $HOME.
You can also fix |
I'm having exactly the same issue as #594. It was closed with a comment that it was the OP's shell configuration that was broken, with no explanation of what exactly needed to be fixed. I've experimented with many things, making sure HOMEBREW_ env vars are set e.g. via
brew shellenv
(my paths were set but the HOMEDIR_ vars were not originally), but none of that has changed the behavior.I believe the response may have been to the FIRST error shown in the command output which was "brew: command not found" however that is resolvable by fixing the environment, which I did. (I have to run the "sudo" version of the command in a root login shell from
sudo -i
so that all the variables will be properly set, but at that point root has the full homebrew environment set.)Then I try to start a brew service, however, I get the SECOND error shown in that posting (which the OP got when specifying the full path in the sudo command) which was:
Besides the annoyance of not being able to use brew directly in a sudo command because sudo strips the environment, can you please clarify what is needed to get this working? Obviously I tried running
brew update
as shown in the error message and it does nothing (since I had already run a brew update prior to attempting the services command.)Interestingly,
brew services ls
works fine under my account, but fails with the same error message when run in the root shell.Host is Ubuntu 20.04 and I was looking for a clean way to get an up-to-date and maintainable installation of fail2ban running. It's the first time I've tried to run any homebrew services on any host. Is this supposed to work?
The text was updated successfully, but these errors were encountered: