Search code examples
centoshomebrewjelastic

How to install Homebrew on Jelastic


I needed to install a repository with brew on my Jelastic Environment, and I ended up facing many difficulties to achieve this, so I decided to share my solution here, hope it helps others out.


Solution

  • It has been a hell of a run, but here is the detailed procedure:

    WARNING: ONLY USE THE PACKAGE INSTALLER OF POINT 1 AS LAST RESOURCE, IT CAN CAUSE MANY PROBLEMS. For example: using it to install composer will downgrade your php binary to v5 permanently, and there is nothing you can do to fix it unless creating a new node, if you decide to use it, first clone your node to have a backup in case it destroyes everything.

    1. Install this package installer following the instructions here: https://github.com/jelastic-jps/packages-installer :

    Then use it to install gcc.

    1. We need to install anaconda in order to update git and curl to a version recent enough to make brew at least run (src: https://stackoverflow.com/a/52561058/12181662 ) :

    curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda.sh bash Miniconda.sh -b -p ~/conda

    1. Use anaconda to install git and curl (src: https://www.reddit.com/r/linux4noobs/comments/lzdo9n/comment/gq1fhak/?utm_source=share&utm_medium=web2x&context=3 ) :
    source /var/www/conda/bin/activate
    
    conda update conda
    conda install git
    conda install curl
    
    conda deactivate
    
    echo 'export PATH="/var/www/conda/bin:$PATH"' >> ~/.bash_profile
    export PATH="/var/www/conda/bin:$PATH"
    
    1. install brew locally (src: https://brew.sh/ ) :
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    echo 'eval "$(/var/www/.linuxbrew/bin/brew shellenv)"' >> /var/www/.bash_profile
    eval "$(/var/www/.linuxbrew/bin/brew shellenv)"
    
    echo 'export HOMEBREW_CURL_PATH="/var/www/conda/bin/curl"' >> ~/.bash_profile
    export HOMEBREW_CURL_PATH="/var/www/conda/bin/curl"
    echo 'export HOMEBREW_GIT_PATH="/var/www/conda/bin/git"' >> ~/.bash_profile
    export HOMEBREW_GIT_PATH="/var/www/conda/bin/git"
    
    1. install the most recent version of gcc using brew (src: https://github.com/Homebrew/homebrew-core/issues/101919#issuecomment-1162740031 ) :
    brew install gcc@5
    brew install --force-bottle gcc
    
    1. fix brew install for the non-root locations (src: https://github.com/orgs/Homebrew/discussions/3421#discussioncomment-3126807 ) :
    echo 'export HOMEBREW_RELOCATE_BUILD_PREFIX=1' >> /var/www/.bash_profile
    export HOMEBREW_RELOCATE_BUILD_PREFIX=1
    
    1. enjoy! Example: brew install composer

    Also you can try to run this is you face any errors during installation of anything:

    brew link --overwrite libxcrypt