Change install location and prefix of homebrew packages

My /usr/local and /usr/local/bin permissions on my machine are different from traditional machines (and they have to be that way).

Is it possible to configure homebrew to install in a different location ~/bin/ instead of /usr/local/bin?

I tried to change HOMEBREW_PREFIX environment variable, however I didn't see the change reflected when I ran brew config

So what I am asking is

  1. Can I change my homebrew install location to my home directory
  2. Can I change prefix of package install locations (packages installed by brew).

Solution 1:

  1. It is possible to install homebrew into your home directory. I followed (more or less) the steps posted here and it succeeded. The exact commands I used:

    cd $HOME
    mkdir bin
    cd bin
    git clone https://github.com/Homebrew/homebrew.git
    

    Then changed the assignment of the PATH variable in my bash profile.

    export PATH=${HOME}/bin/homebrew/bin:${PATH}
    

    However, this is specifically discouraged by Homebrew developers on their installation documentation. I can confirm that several packages worked (seqtk, pear) while others failed (wget, homebrew/science/blast, jags). I am also unable to change the ownership of my /usr/local directory, so I'm back to compiling those packages manually.

  2. No, not to my knowledge. See this question.