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