I am using aurora-dx-hwe latest. I installed a dependency for a download bash script. When I run the bash script as my user, it can find the dependency installed by homebrew. The program needs root access as it writes to a USB drive. When I run it with sudo, it says it can’t find the program. How can I use things installed with homebrew when running with sudo?
I am not sure what else to do, as installing packages with dnf is cumbersome and discouraged.
Sounds like homebrew isn’t in the $PATH of your root user. You can verify by comparing the output of env | grep ^PATH vs sudo env | grep ^PATH.
A few options:
Can you mount your USB drive as your user or chown the files/directories you need access to on the USB drive to your user? That way, you don’t need to run anything as root
If not, you can add the linuxbrew bin dir to the PATH when you run the executable you need
For example, I have rclone installed with brew but by default I can’t just use sudo to call it:
afidel@thinkpad:~$ sudo rclone --version
sudo: rclone: command not found
I wasn’t sure it was a good idea to add it to the root user’s path permanently. I edited the script to have linuxbrew in the path and that worked. In the future, is it a good idea to add linuxbrew to the root user? Can any harm come out of it?
In my opinion, it’s fine to include linuxbrew’s bin directory in the root user’s PATH by default but it’s probably best to either fully qualify the full path of the brew program you want to run or use it in a case by case basis.
There could be some strange edge cases when using linuxbrew’s bin dir early in the PATH. For example, I for some reason had systemd installed as a dependency in some brew package and brew’s version of systemctl would be used instead of the system’s systemctl.
Use /etc/bash/bashrc for system-wide PATH modification.
BREWPATH="/home/${USER}/.linuxbrew/bin:/home/${USER}/.linuxbrew/sbin"
# Interchange the two variables' order if you have the problem stated in the post just above
export PATH="${BREWPATH}:${PATH}"
How is the dependent package supposed to use systemd packaged in homebrew? How is systemd even supposed to work that way?
Some issue in the package itself mostly.