安装 Homebrew 后弹出消息

安装 Homebrew 后弹出消息

安装 Homebrew 后,每次启动或重新启动 Ubuntu 时都会弹出此消息:

Error found when loading /home/lentakit/.profile
/home/lentkit/.profile line 21 brew: command not found
/home/lentkit/.profile line 22 brew: command not found
As a result the session will not be configured correctly 
Fix the problem as soon as feasible

这是运行的结果cat -n /home/lentakit/.profile

     1  # ~/.profile: executed by the command interpreter for login shells.
 2  # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
 3  # exists.
 4  # see /usr/share/doc/bash/examples/startup-files for examples.
 5  # the files are located in the bash-doc package.
 6  
 7  # the default umask is set in /etc/profile; for setting the umask
 8  # for ssh logins, install and configure the libpam-umask package.
 9  #umask 022
10  
11  # if running bash
12  if [ -n "$BASH_VERSION" ]; then
13      # include .bashrc if it exists
14      if [ -f "$HOME/.bashrc" ]; then
15      . "$HOME/.bashrc"
16      fi
17  fi
18  
19  # set PATH so it includes user's private bin directories
20  PATH="$HOME/bin:$HOME/.local/bin:$PATH"
21  export PATH="$(brew --prefix)/bin:$PATH"
22  export PATH="$(brew --prefix)/bin:$PATH"
23  export PATH="$(brew --prefix)/bin:$PATH"

我应该怎么办 ?

答案1

据说来自这里将其添加到您的PATH运行后:

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

您是否将以下内容添加到了~/.profile?:

test -d ~/.linuxbrew && PATH="$HOME/.linuxbrew/bin:$PATH"
test -d /home/linuxbrew/.linuxbrew && PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
test -r ~/.bash_profile && echo 'export PATH="$(brew --prefix)/bin:$PATH"' >>~/.bash_profile
echo 'export PATH="$(brew --prefix)/bin:$PATH"' >>~/.profile

现在,如果上述操作已完成,请检查这些行是否~/.bash_profile

export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
export MANPATH="/home/linuxbrew/.linuxbrew/share/man:$MANPATH"
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:$INFOPATH"
export PATH="$(brew --prefix)/bin:$PATH"

那么这是~/.profile

export PATH="$(brew --prefix)/bin:$PATH"

现在运行下面这行代码,将此行添加到你的/home/$USER/.bashrc

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

~/.bashrc使用 .作为源source ~/.bashrc,现在关闭所有终端并重新启动终端并输入:'which brew' 你应该看到:

/home/linuxbrew/.linuxbrew/bin/brew

如果做得对的话。

答案2

转到 /home/lentkit(lenkit 是您的配置文件名称)并在文本编辑器中打开 .profile 文件(最好是 vscode,这样您就可以找到确切的行)。转到错误中提到的行。在本例中为 21,然后将其删除。实际上,删除与 linuxbrew 或 home brew 有关的每一行。此解决方案仅适用于从您的系统中彻底删除 homebrew。

答案3

打开终端,输入gedit .profile,从开始到结束删除所有 brew 命令。保存并重新启动。它应该可以修复该错误。

警告: Brew 将被彻底删除。

相关内容