This tutorial took awhile, i've been trying to figure this out for a long time.
If you don't know, Homebrew is a package manager (like npm), written in ruby, for Mac OS X and Linux. Replit's VM is a Linux, but with a lot of restrictions. (no sudo, no root access, etc.)
To install it, type this in the terminal, or in a bash file:
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
export PATH="$(pwd)/homebrew/bin:$PATH" && brew
Now, you can use Homebrew!
export PATH="$(pwd)/homebrew/bin:$PATH" whenever you want to use something.