简体   繁体   English

我可以在 Ubuntu 上使用 Homebrew 吗?

[英]Can I use Homebrew on Ubuntu?

I just tried to use Homebrew and Linuxbrew to install packages on my Ubuntu Server but both failed.我只是尝试使用 Homebrew 和 Linuxbrew 在我的 Ubuntu 服务器上安装软件包,但都失败了。 This is how I tried to install them:这就是我尝试安装它们的方式:

sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"

I got the following warning:我收到以下警告:

Warning: /home/tong/.linuxbrew/bin is not in your PATH.

I vi my bash.bashrc in home/etc and add this:我在 home/etc 中查看我的 bash.bashrc 并添加:

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

Then I tried brew doctor but got No command 'brew' found .然后我尝试了brew doctor但得到了No command 'brew' found How am I able to use Homebrew on Ubuntu?如何在 Ubuntu 上使用 Homebrew?

As of February 2018, installing brew on Ubuntu (mine is 17.10) machine is as simple as:截至 2018 年 2 月,在 Ubuntu(我的是 17.10)机器上安装brew非常简单:

sudo apt install linuxbrew-wrapper

Then, on first brew execution (just type brew --help ) you will be asked for two installation options:然后,在第一次brew执行时(只需输入brew --help ),您将被要求提供两个安装选项:

me@computer:~/$ brew --help
==> Select the Linuxbrew installation directory
- Enter your password to install to /home/linuxbrew/.linuxbrew (recommended)
- Press Control-D to install to /home/me/.linuxbrew
- Press Control-C to cancel installation
[sudo] password for me:

For recommended option type your password (if your current user is in sudo group), or, if you prefer installing all the dependencies in your own home folder, hit Ctrl + D .对于推荐的选项,请输入您的密码(如果您的当前用户在sudo组中),或者,如果您希望将所有依赖项安装在您自己的主文件夹中,请按 Ctrl + D Enjoy.享受。

I just tried installing it using the ruby command but somehow the dependencies are not resolved hence brew does not completely install.我只是尝试使用 ruby​​ 命令安装它,但不知何故,依赖关系没有解决,因此 brew 没有完全安装。 But, try installing by cloning:但是,尝试通过克隆安装:

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

and then add the following to your .bash_profile :然后将以下内容添加到您的.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..它应该工作..

as of august 2020 (works for kali linux as well)截至 2020 年 8 月(也适用于 kali linux)

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

export brew=/home/linuxbrew/.linuxbrew/bin

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)

test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

test -r ~/.profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile     // for ubuntu and debian

The following steps worked for me:以下步骤对我有用:

  • Clone it from github从 github 克隆它

    git clone https://github.com/Homebrew/linuxbrew.git ~/.linuxbrew
  • Open your .bash_profile file using vi ~/.bash_profile使用vi ~/.bash_profile打开你的 .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.在终端中键入brew以检查其存在。

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.您可以按照Homebrew on Linux docs中的说明进行操作,但我认为最好了解说明要达到的目的。

Understanding the installation steps can save some time了解安装步骤可以节省一些时间


Step 1: Choose location第 1 步:选择位置

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).首先,重要的是要了解linuxbrew将安装在/home目录中,而不是/home/your-user~目录)中。
(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 :第 2 步:将linuxbrew二进制文件添加到/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第 3 步:检查/linuxbrew是否已添加到相关位置

This can be done by simply navigating to /home .这可以通过简单地导航到/home来完成。
Notice that the docs are showing it as a one-liner by adding test -d <linuxbrew location> before each command.请注意,文档通过在每个命令之前添加test -d <linuxbrew location>将其显示为单行。

(Read more about the test command in here ). (在此处阅读有关test命令的更多信息)。

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.我们需要将linuxbrew添加到PATH并在当前终端中添加更多的环境变量。

We can just add the following export s to terminal (wait don't do it..):我们可以将以下export添加到终端(等等不要这样做..):

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):或者简单地运行(如果您的linuxbrew文件夹位于其他位置,则/home - 更改路径):

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 (*) 因为当前终端尚未识别brew命令(这是我们现在正在解决的问题),我们必须指定 brew 二进制文件的完整路径: /home/linuxbrew/.linuxbrew/bin/brew shellenv

Test this step by:通过以下方式测试此步骤:

1 ) Run brew from current terminal to see if it identifies the command. 1 ) 从当前终端运行brew以查看它是否识别命令。

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 . 2 ) 运行printenv并检查是否所有环境变量都已导出,并且您在PATH上看到/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin

Step 5: Ensure step 4 is running on each terminal第 5 步:确保第 4 步在每个终端上运行

We need to add step 4 to ~/.profile (in case of Debian/Ubuntu):我们需要将第 4 步添加到~/.profile (在 Debian/Ubuntu 的情况下):

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

For CentOS/Fedora/Red Hat - replace ~/.profile with ~/.bash_profile .对于 CentOS/Fedora/Red Hat - 将~/.profile替换为~/.bash_profile

Step 6: Ensure that ~/.profile or ~/.bash_profile are being executed when new terminal is opened第 6 步:确保在打开新终端时正在执行~/.profile~/.bash_profile

If you executed step 5 and failed to run brew from new terminal - add a test command like echo "Hi!"如果您执行了第 5 步并且未能从新终端运行brew - 添加一个测试命令,例如echo "Hi!" to ~/.profile or ~/.bash_profile .~/.profile~/.bash_profile
If you don't see Hi!如果你没有看到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.当您打开一个新终端时 - 转到终端首选项并确保设置了“ run command as login shell ”的属性。
Read more in here .这里阅读更多。


Why the installation script installs Homebrew to /home/linuxbrew/.linuxbrew - from here :为什么安装脚本将 Homebrew 安装到/home/linuxbrew/.linuxbrew - 从这里

The installation script installs Homebrew to /home/linuxbrew/.linuxbrew using sudo if possible and in your home directory at ~/.linuxbrew otherwise.如果可能,安装脚本会使用sudo将 Homebrew 安装到/home/linuxbrew/.linuxbrew ,否则安装到您的主目录~/.linuxbrew Homebrew does not use sudo after installation. Homebrew 安装后不使用sudo
Using /home/linuxbrew/.linuxbrew allows the use of more binary packages (bottles) than installing in your personal home directory.使用/home/linuxbrew/.linuxbrew允许使用比安装在您的个人主目录中更多的二进制包(瓶子)。

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.选择前缀/home/linuxbrew/.linuxbrew以便没有管理员访问权限的用户可以要求管理员创建一个linuxbrew角色帐户,并且仍然可以从预编译的二进制文件中受益。

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 .如果您自己没有管理员权限,请考虑让您的管理员人员使用主目录/home/linuxbrew为您创建一个linuxbrew角色帐户。

Linux is now officially supported in brew - see the Homebrew 2.0.0 blog post. brew 现在正式支持 Linux - 请参阅Homebrew 2.0.0博客文章。 As shown on https://brew.sh , just copy/paste this into a command prompt:https://brew.sh所示,只需将其复制/粘贴到命令提示符中:

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

Because all previous answers doesn't work for me for ubuntu 14.04 here what I did, if any one get the same problem:因为所有以前的答案都不适用于 ubuntu 14.04 在这里我所做的,如果有人遇到同样的问题:

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.您可以点击此链接了解更多信息。

October 2019 - Ubuntu 18.04 on WSL with oh-my-zsh; 2019 年 10 月 - 带有 oh-my-zsh 的 WSL 上的 Ubuntu 18.04; the instructions here worked perfectly -这里的说明效果很好 -

(first, install pre-requisites using sudo apt-get install build-essential curl file git ) (首先,使用sudo apt-get install build-essential curl file git安装先决条件)

finally create a ~/.zprofile with the following contents: emulate sh -c '. ~/.profile'最后创建一个具有以下内容的~/.zprofile : emulate emulate sh -c '. ~/.profile' emulate sh -c '. ~/.profile'

Whta to do做什么

   cd /home/linuxbrew/.linuxbrew/bin
    ./brew doctor

You will get what path to export您将获得导出的路径

   echo 'export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"' >> ~/.zshrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在Ubuntu中使用转储 - Can not use dump in ubuntu 我可以使用Ubuntu创建Apple iPod / iPhone / iPad应用程序吗? - Can I use Ubuntu to create a Apple iPod/iPhone/iPad app? 我可以在Raspberry Pi 2 Model B上将此版本的Ubuntu使用picamera吗? - Can I use picamera with this version of Ubuntu on a Raspberry Pi 2 Model B? 我正在尝试在我的 32 位 ubuntu 机器上安装自制软件。 但它不工作,我得到了这个错误 - I'm trying to install homebrew in my 32 bit ubuntu machine. But it's not working and I got this error 在自制软件中,我怎么知道xargs属于findutil包? - In homebrew, how can I know xargs belongs to the findutil package? 我可以在Ubuntu 14.04上开发Java Web应用程序并使用我的Apache服务器查看它们吗? - Can I Develop Java Web Applications On Ubuntu 14.04 And Use My Apache Server To View Them? MySQL在Ubuntu根文件系统中使用空间,我该如何更改使用 - MySQL using space in the Ubuntu root filesysem, how can I change to use 在ubuntu服务器上安装了libphp-mailer,如何在Web项目中使用它? - Installed libphp-mailer on ubuntu server, how can I use it in web projects? 我如何使用小程序通过ubuntu上的rxtxComm.jar将数据发送到串行端口 - How can i use applet send data to serial port via rxtxComm.jar On ubuntu 我如何在Ubuntu中使用CMake宏 - How do i use a CMake Macro in ubuntu
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM