A cleaner solution is to install homebrew into a custom location in a user's folder - use ~/homebrew/. Don't touch /opt/homebrew folder
Configure homebrew for use with a local folder. Here's how you can do it:
- Clone homebrew to a local directory, e.g., if you want to have it in
~/homebrew, run the commandgit clone https://github.com/Homebrew/brew ~/homebrew - Add brew binary folders to the
PATHenvironmental variable:echo 'export PATH="$HOME/homebrew/bin:$HOME/homebrew/sbin:$PATH"' >> ~/.bash_profile, thensource ~/.bash_profile - Run
brew update; then use brew as you normally would, e.g.brew install octave
Putting brew into a user-owned folder is a clean solution but it is also not without peril - homebrew will be compiling all packages from source code, leading to longer install times.
Finally, when browsing your filesystem, you might notice that there is a folder in /opt/homebrew, yet there is no brew executable anywhere near it. This folder is created by yum package manager and should not be touched.