Can I use Homebrew on Ubuntu?

后端 未结 8 425
[愿得一人]
[愿得一人] 2021-01-30 02:45

I just tried to use Homebrew and Linuxbrew to install packages on my Ubuntu Server but both failed. This is how I tried to install them:

sudo apt-get install bui         


        
相关标签:
8条回答
  • 2021-01-30 02:56

    Linux is now officially supported in brew - see the Homebrew 2.0.0 blog post. As shown on https://brew.sh, just copy/paste this into a command prompt:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    
    0 讨论(0)
  • 2021-01-30 03:02

    Because all previous answers doesn't work for me for ubuntu 14.04 here what I did, if any one get the same problem:

    git clone https://github.com/Linuxbrew/brew.git ~/.linuxbrew
    PATH="$HOME/.linuxbrew/bin:$PATH"
    export MANPATH="$(brew --prefix)/share/man:$MANPATH"
    export INFOPATH="$(brew --prefix)/share/info:$INFOPATH"
    

    then

    sudo apt-get install gawk
    sudo yum install gawk
    brew install hello
    

    you can follow this link for more information.

    0 讨论(0)
  • 2021-01-30 03:03

    October 2019 - Ubuntu 18.04 on WSL with oh-my-zsh; the instructions here worked perfectly -

    (first, install pre-requisites using sudo apt-get install build-essential curl file git)

    finally create a ~/.zprofile with the following contents: emulate sh -c '. ~/.profile'

    0 讨论(0)
  • 2021-01-30 03:04

    I just tried installing it using the ruby command but somehow the dependencies are not resolved hence brew does not completely install. But, try installing by cloning:

    git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew
    

    and then add the following to your .bash_profile:

    export PATH="$HOME/.linuxbrew/bin:$PATH"
    export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
    export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
    

    It should work..

    0 讨论(0)
  • 2021-01-30 03:07

    You can just follow instructions from the Homebrew on Linux docs, but I think it is better to understand what the instructions are trying to achieve.

    Understanding the installation steps can save some time


    Step 1: Choose location

    First of all, it is important to understand that linuxbrew will be installed on the /home directory and not inside /home/your-user (the ~ directory).
    (See the reason for that at the end of answer).
    Keep this in mind when you run the other steps below.

    Step 2: Add linuxbrew binaries to /home :

    The installation script will do it for us:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    

    Step 3: Check that /linuxbrew was added to the relevant location

    This can be done by simply navigating to /home.
    Notice that the docs are showing it as a one-liner by adding test -d <linuxbrew location> before each command.

    (Read more about the test command in here).

    Step 4: Export relevant environment variables to terminal

    We need to add linuxbrew to PATH and add some more environment variables to the current terminal.

    We can just add the following exports to terminal (wait don't do it..):

    export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
    
    export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
    export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
    export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
    export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
    export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}";
    

    Or simply run (If your linuxbrew folder is on other location then /home - change the path):

    eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
    

    (*) Because brew command is not yet identified by the current terminal (this is what we're solving right now) we'll have to specify the full path to the brew binary: /home/linuxbrew/.linuxbrew/bin/brew shellenv

    Test this step by:

    1 ) Run brew from current terminal to see if it identifies the command.

    2 ) Run printenv and check if all environment variables were exported and that you see /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin on PATH.

    Step 5: Ensure step 4 is running on each terminal

    We need to add step 4 to ~/.profile (in case of Debian/Ubuntu):

    echo "eval \$($(brew --prefix)/bin/brew shellenv)" >> ~/.profile
    

    For CentOS/Fedora/Red Hat - replace ~/.profile with ~/.bash_profile.

    Step 6: Ensure that ~/.profile or ~/.bash_profile are being executed when new terminal is opened

    If you executed step 5 and failed to run brew from new terminal - add a test command like echo "Hi!" to ~/.profile or ~/.bash_profile.
    If you don't see Hi! when you open a new terminal - go to the terminal preferences and ensure that the attribute of 'run command as login shell' is set.
    Read more in here.


    Why the installation script installs Homebrew to /home/linuxbrew/.linuxbrew - from here:

    The installation script installs Homebrew to /home/linuxbrew/.linuxbrew using sudo if possible and in your home directory at ~/.linuxbrew otherwise. Homebrew does not use sudo after installation.
    Using /home/linuxbrew/.linuxbrew allows the use of more binary packages (bottles) than installing in your personal home directory.

    The prefix /home/linuxbrew/.linuxbrew was chosen so that users without admin access can ask an admin to create a linuxbrew role account and still benefit from precompiled binaries.

    If you do not yourself have admin privileges, consider asking your admin staff to create a linuxbrew role account for you with home directory /home/linuxbrew.

    0 讨论(0)
  • 2021-01-30 03:11

    The following steps worked for me:

    • Clone it from github

      git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew
      
    • Open your .bash_profile file using vi ~/.bash_profile

    • Add these lines

      export PATH="$HOME/.linuxbrew/bin:$PATH"
      export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
      export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
      
    • Then type the following lines in your terminal

      export PATH=$HOME/.linuxbrew/bin:$PATH
      hash -r
      

    Yes, it is done. Type brew in your terminal to check its existence.

    0 讨论(0)
提交回复
热议问题