Skip to content
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

Brew not available as root on host #243

Open
bshor opened this issue Apr 4, 2024 · 1 comment
Open

Brew not available as root on host #243

bshor opened this issue Apr 4, 2024 · 1 comment

Comments

@bshor
Copy link

bshor commented Apr 4, 2024

I am running Bazzite with the latest image.

There are some apps I need to run as root on the host, for example httm. After installing brew with ujust brew, I am able to install apps into my user directory just fine. But I can't run brew as root, or access an app installed in my user directory as root, which is kind of a catch-22.

So, sudo brew returns sudo: brew: command not found. And if I install say httm as a user, when I try sudo httm I also get command not found. But the command can't be run as a plain user.

What should I do?

@m2Giles
Copy link
Member

m2Giles commented Apr 7, 2024

The reason why brew commands are not showing up when using brew applications is due to the fact that sudo does not have the same environment as you.

httm in your case exists at /var/home/linuxbrew/.linuxbrew/bin/httm and when sudo executes something it executes it as a non-login shell. We add the brew path via /etc/profile.d which is only sourced by login shells for bash/zsh (Fish is different but similar idea applies).

You should be able to run your httm command with sudo if you give it the absolute path. You can also use sudo -E to preserve your entire environment (which can be a security issue) or sudo --preserve-env=PATH to specifically preserve your PATH. You also can use sudo -i to start a login shell with root. sudo -i httm may work as well.

For sudo brew, brew doesn't like running as root since that would mean all build scripts would have access to your system. Brew for the most part should only be writing to /var/home/linuxbrew/.linuxbrew which is owned by the user who ran ujust brew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants